![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtGui More...
#include <qpixelformat.h>
Public Types | |
enum | ColorModel { RGB , BGR , Indexed , Grayscale , CMYK , HSL , HSV , YUV , Alpha } |
This enum describes the \l{colorModel()}{color model} of the pixel format. More... | |
enum | AlphaUsage { UsesAlpha , IgnoresAlpha } |
This enum describes the \l{alphaUsage()}{alpha usage} of the pixel format. More... | |
enum | AlphaPosition { AtBeginning , AtEnd } |
This enum describes the \l{alphaPosition()}{alpha position} of the pixel format. More... | |
enum | AlphaPremultiplied { NotPremultiplied , Premultiplied } |
This enum describes whether the alpha channel of the pixel format is \l{premultiplied}{premultiplied} into the color channels or not. More... | |
enum | TypeInterpretation { UnsignedInteger , UnsignedShort , UnsignedByte , FloatingPoint } |
This enum describes the \l{typeInterpretation()}{type interpretation} of the pixel format. More... | |
enum | YUVLayout { YUV444 , YUV422 , YUV411 , YUV420P , YUV420SP , YV12 , UYVY , YUYV , NV12 , NV21 , IMC1 , IMC2 , IMC3 , IMC4 , Y8 , Y16 } |
This enum describes the \l{yuvLayout()}{YUV layout} of the pixel format, given that it has a color model of QPixelFormat::YUV. More... | |
enum | ByteOrder { LittleEndian , BigEndian , CurrentSystemEndian } |
This enum describes the \l{byteOrder()}{byte order} of the pixel format. More... |
Public Member Functions | |
constexpr | QPixelFormat () noexcept |
Creates a null pixelformat. | |
constexpr | QPixelFormat (ColorModel colorModel, uchar firstSize, uchar secondSize, uchar thirdSize, uchar fourthSize, uchar fifthSize, uchar alphaSize, AlphaUsage alphaUsage, AlphaPosition alphaPosition, AlphaPremultiplied premultiplied, TypeInterpretation typeInterpretation, ByteOrder byteOrder=CurrentSystemEndian, uchar subEnum=0) noexcept |
Creates a QPixelFormat which assigns its data to the attributes. | |
constexpr ColorModel | colorModel () const noexcept |
Accessor function for the color model. | |
constexpr uchar | channelCount () const noexcept |
Accessor function for the channel count. | |
constexpr uchar | redSize () const noexcept |
Accessor function for the size of the red color channel. | |
constexpr uchar | greenSize () const noexcept |
Accessor function for the size of the green color channel. | |
constexpr uchar | blueSize () const noexcept |
Accessor function for the size of the blue color channel. | |
constexpr uchar | cyanSize () const noexcept |
Accessor function for the cyan color channel. | |
constexpr uchar | magentaSize () const noexcept |
Accessor function for the megenta color channel. | |
constexpr uchar | yellowSize () const noexcept |
Accessor function for the yellow color channel. | |
constexpr uchar | blackSize () const noexcept |
Accessor function for the black/key color channel. | |
constexpr uchar | hueSize () const noexcept |
Accessor function for the hue channel size. | |
constexpr uchar | saturationSize () const noexcept |
Accessor function for the saturation channel size. | |
constexpr uchar | lightnessSize () const noexcept |
Accessor function for the lightness channel size. | |
constexpr uchar | brightnessSize () const noexcept |
Accessor function for the brightness channel size. | |
constexpr uchar | alphaSize () const noexcept |
Accessor function for the alpha channel size. | |
constexpr uchar | bitsPerPixel () const noexcept |
Accessor function for the bits used per pixel. | |
constexpr AlphaUsage | alphaUsage () const noexcept |
Accessor function for whether the alpha channel is used or not. | |
constexpr AlphaPosition | alphaPosition () const noexcept |
Accessor function for the position of the alpha channel relative to the color channels. | |
constexpr AlphaPremultiplied | premultiplied () const noexcept |
Accessor function for the whether the alpha channel is multiplied in to the color channels. | |
constexpr TypeInterpretation | typeInterpretation () const noexcept |
The type interpretation determines how each pixel should be read. | |
constexpr ByteOrder | byteOrder () const noexcept |
The byte order of the pixel format determines the memory layout of the individual type units, as described by the typeInterpretation(). | |
constexpr YUVLayout | yuvLayout () const noexcept |
Accessor function for the YUVLayout. | |
constexpr uchar | subEnum () const noexcept |
Accessor for the datapart which contains subEnums This is the same as the yuvLayout() function. |
Friends | |
Q_DECL_CONST_FUNCTION constexpr bool | operator== (QPixelFormat fmt1, QPixelFormat fmt2) |
Q_DECL_CONST_FUNCTION constexpr bool | operator!= (QPixelFormat fmt1, QPixelFormat fmt2) |
Q_GUI_EXPORT QDebug | operator<< (QDebug debug, const QPixelFormat &format) |
\inmodule QtGui
QPixelFormat is a class for describing different pixel layouts in graphics buffers.
In Qt there is a often a need to represent the layout of the pixels in a graphics buffer. QPixelFormat can describe up to 5 color channels and 1 alpha channel, including details about how these channels are represented in memory individually and in relation to each other.
The typeInterpretation() and byteOrder() determines how each pixel should be read/interpreted, while alphaSize(), alphaUsage(), alphaPosition(), and premultiplied() describes the position and properties of the possible alpha channel.
There is no support for describing YUV's macro pixels. Instead a list of \l{QPixelFormat::YUVLayout}{YUV formats} is provided. When a QPixelFormat describes a YUV format, the bitsPerPixel() value is deduced from the YUV layout.
Definition at line 12 of file qpixelformat.h.
This enum describes the \l{alphaPosition()}{alpha position} of the pixel format.
\value AtBeginning The alpha channel will be put in front of the color channels. E.g. ARGB.
\value AtEnd The alpha channel will be put in the back of the color channels. E.g. RGBA.
Enumerator | |
---|---|
AtBeginning | |
AtEnd |
Definition at line 90 of file qpixelformat.h.
This enum describes whether the alpha channel of the pixel format is \l{premultiplied}{premultiplied} into the color channels or not.
\value NotPremultiplied The alpha channel is not multiplied into the color channels.
\value Premultiplied The alpha channel is multiplied into the color channels.
Enumerator | |
---|---|
NotPremultiplied | |
Premultiplied |
Definition at line 96 of file qpixelformat.h.
This enum describes the \l{alphaUsage()}{alpha usage} of the pixel format.
\value IgnoresAlpha The alpha channel is not used.
\value UsesAlpha The alpha channel is used.
Enumerator | |
---|---|
UsesAlpha | |
IgnoresAlpha |
Definition at line 84 of file qpixelformat.h.
This enum describes the \l{byteOrder()}{byte order} of the pixel format.
\value LittleEndian The byte order is little endian. \value BigEndian The byte order is big endian. \value CurrentSystemEndian This enum will not be stored, but is converted in the constructor to the endian enum that matches the enum of the current system.
Enumerator | |
---|---|
LittleEndian | |
BigEndian | |
CurrentSystemEndian |
Definition at line 130 of file qpixelformat.h.
This enum describes the \l{colorModel()}{color model} of the pixel format.
\value RGB The color model is RGB.
\value BGR This is logically the opposite endian version of RGB. However, for ease of use it has its own model.
\value Indexed The color model uses a color palette.
\value Grayscale The color model is Grayscale.
\value CMYK The color model is CMYK.
\value HSL The color model is HSL.
\value HSV The color model is HSV.
\value YUV The color model is YUV.
\value Alpha [since 5.5] There is no color model, only alpha is used.
Enumerator | |
---|---|
RGB | |
BGR | |
Indexed | |
Grayscale | |
CMYK | |
HSL | |
HSV | |
YUV | |
Alpha |
Definition at line 71 of file qpixelformat.h.
This enum describes the \l{typeInterpretation()}{type interpretation} of the pixel format.
\value UnsignedInteger The pixels should be read as one or more {unsigned int}. \value UnsignedShort The pixels should be read as one or more
{unsigned short}. \value UnsignedByte The pixels should be read as one or more
{byte}. \value FloatingPoint The pixels should be read as one or more floating point numbers, with the concrete type defined by the color/alpha channel, ie.
{qfloat16} for 16-bit half-float formats and
{float} for 32-bit full-float formats.
Enumerator | |
---|---|
UnsignedInteger | |
UnsignedShort | |
UnsignedByte | |
FloatingPoint |
Definition at line 102 of file qpixelformat.h.
This enum describes the \l{yuvLayout()}{YUV layout} of the pixel format, given that it has a color model of QPixelFormat::YUV.
\value YUV444 \value YUV422 \value YUV411 \value YUV420P \value YUV420SP \value YV12 \value UYVY \value YUYV \value NV12 \value NV21 \value IMC1 \value IMC2 \value IMC3 \value IMC4 \value Y8 \value Y16
Enumerator | |
---|---|
YUV444 | |
YUV422 | |
YUV411 | |
YUV420P | |
YUV420SP | |
YV12 | |
UYVY | |
YUYV | |
NV12 | |
NV21 | |
IMC1 | |
IMC2 | |
IMC3 | |
IMC4 | |
Y8 | |
Y16 |
Definition at line 110 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Creates a null pixelformat.
This format maps to QImage::Format_Invalid.
Definition at line 137 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Creates a QPixelFormat which assigns its data to the attributes.
colorModel will be put into a buffer which is 4 bits long.
firstSize secondSize thirdSize fourthSize fifthSize alphaSize are all meant to represent the size of a channel. The channels will be used for different uses dependent on the colorModel. For RGB the firstSize will represent the Red channel. On CMYK it will represent the value of the Cyan channel.
alphaUsage represents if the alpha channel is used or not.
alphaPosition is the position of the alpha channel.
premultiplied represents if the alpha channel is already multiplied with the color channels.
typeInterpretation is how the pixel is interpreted.
byteOrder represents the endianness of the pixelformat. This defaults to CurrentSystemEndian, which will be resolve to the system's endianness for non-byte-ordered formats, and QPixelFormat::BigEndian for QPixelFormat::UnsignedByte.
subEnum is used for colorModels that have to store some extra information with supplying an extra enum. This is used by YUV to store the YUV type The default value is 0.
Definition at line 224 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the position of the alpha channel relative to the color channels.
For formats where the individual channels map to individual units, the alpha position is relative to these units. For example for QImage::Format_RGBA16FPx4 which has an alpha position of QPixelFormat::AtEnd, the alpha is the last {qfloat16} read.
For formats where multiple channels are packed into a single unit, the QPixelFormat::AtBeginning and QPixelFormat::AtEnd values map to the most significant and least significant bits of the packed unit, with respect to the format's own byteOrder().
For example, for QImage::Format_ARGB32, which has a type interpretation of QPixelFormat::UnsignedInteger and a byteOrder() that always matches the host system, the alpha position of QPixelFormat::AtBeginning means that the alpha can always be found at {0xFF000000}.
If the pixel format and host endianness does {not} match care must be taken to correctly map the pixel format layout to the host memory layout.
Definition at line 184 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the alpha channel size.
Definition at line 174 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for whether the alpha channel is used or not.
Sometimes the pixel format reserves place for an alpha channel, so alphaSize() will return > 0, but the alpha channel is not used/ignored.
For example, for QImage::Format_RGB32, the bitsPerPixel() is 32, because the alpha channel has a size of 8, but alphaUsage() reflects QPixelFormat::IgnoresAlpha.
Note that in such situations the \l{alphaPosition()}{position} of the unused alpha channel is still important, as it affects the placement of the color channels.
Definition at line 183 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the bits used per pixel.
This function returns the sum of all the color channels + the size of the alpha channel.
Definition at line 176 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the black/key color channel.
Definition at line 167 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the size of the blue color channel.
Definition at line 162 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the brightness channel size.
Definition at line 172 of file qpixelformat.h.
|
inlineconstexprnoexcept |
The byte order of the pixel format determines the memory layout of the individual type units, as described by the typeInterpretation().
This function will never return QPixelFormat::CurrentSystemEndian as this value is translated to the system's endian value in the constructor.
For pixel formats with typeInterpretation() QPixelFormat::UnsignedByte this will typically be QPixelFormat::BigEndian, while other type interpretations will typically reflect the endianness of the current system.
If the byte order of the pixel format matches the current system the individual type units can be read and manipulated using the same bit masks and operations, regardless of the host system endianness. For example, with QImage::Format_ARGB32, which has a QPixelFormat::UnsignedInteger type interpretation, the alpha can always be read by masking the {unsigned int} by
{0xFF000000}, regardless of the host endianness.
If the pixel format and host endianness does {not} match care must be taken to account for this. Classes like QImage do not swap the internal bits to match the host system endianness in these cases.
Definition at line 187 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the channel count.
The channel count represents channels (color and alpha) with a size > 0.
Definition at line 153 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the color model.
Note that for QPixelFormat::YUV the individual macro pixels can not be described. Instead a list of \l{QPixelFormat::YUVLayout}{YUV formats} is provided, and the bitsPerPixel() value is deduced from the YUV layout.
Definition at line 152 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the cyan color channel.
Definition at line 164 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the size of the green color channel.
Definition at line 161 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the hue channel size.
Definition at line 169 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the lightness channel size.
Definition at line 171 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the megenta color channel.
Definition at line 165 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the whether the alpha channel is multiplied in to the color channels.
Definition at line 185 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the size of the red color channel.
Definition at line 160 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the saturation channel size.
Definition at line 170 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor for the datapart which contains subEnums This is the same as the yuvLayout() function.
Definition at line 190 of file qpixelformat.h.
|
inlineconstexprnoexcept |
The type interpretation determines how each pixel should be read.
Each pixel is represented as one or more units of the given type, laid out sequentially in memory.
For example, QImage::Format_Mono has a \l{QImage::pixelFormat()}{pixel format} of 1 bits per pixel and a QPixelFormat::UnsignedByte type interpretation, which should be read as a single {byte}. Similarly, QImage::Format_RGB888 has a \l{QImage::pixelFormat()}{pixel format} of 24 bits per pixel, and and a QPixelFormat::UnsignedByte type interpretation, which should be read as three consecutive
{byte}s.
Many of the QImage \l{QImage::Format}{formats} are 32-bit with a type interpretation of QPixelFormat::UnsignedInteger, which should be read as a single {unsigned int}.
For QPixelFormat::FloatingPoint formats like QImage::Format_RGBA16FPx4 or QImage::Format_RGBA32FPx4 the type is determined based on the size of the individual color/alpha channels, with {qfloat16} for 16-bit half-float formats and
{float} for 32-bit full-float formats.
Definition at line 186 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the yellow color channel.
Definition at line 166 of file qpixelformat.h.
|
inlineconstexprnoexcept |
Accessor function for the YUVLayout.
It is difficult to describe the color channels of a YUV pixel format since YUV color model uses macro pixels. Instead the layout of the pixels are stored as an enum.
Definition at line 189 of file qpixelformat.h.
|
friend |
Definition at line 203 of file qpixelformat.h.
|
friend |
Definition at line 610 of file qpixelformat.cpp.
|
friend |
Definition at line 200 of file qpixelformat.h.
|
Constructor function for creating an Alpha format. A mask format can be described by passing 1 to channelSize. Its also possible to define very accurate alpha formats using doubles to describe each pixel by passing 8 as channelSize and FloatingPoint as typeInterpretation.
Definition at line 292 of file qpixelformat.h.
|
Constructor function for creating CMYK formats.
The channel count will be 4 or 5 depending on if alphaSize is bigger than zero or not. The CMYK color channels will all be set to the value of channelSize.
alphaUsage alphaPosition and typeInterpretation are all accessible with the accessors with the same name.
Definition at line 308 of file qpixelformat.h.
|
Constructor function for creating a Grayscale format.
Monochrome formats can be described by passing 1 to channelSize. Its also possible to define very accurate grayscale formats using doubles to describe each pixel by passing 8 as channelSize and FloatingPoint as typeInterpretation.
Definition at line 276 of file qpixelformat.h.
|
Constructor function for creating HSL formats.
The channel count will be 3 or 4 depending on if alphaSize is bigger than 0.
channelSize will set the hueSize saturationSize and lightnessSize to the same value.
alphaUsage alphaPosition and typeInterpretation are all accessible with the accessors with the same name.
Definition at line 327 of file qpixelformat.h.
|
Constructor function for creating HSV formats.
The channel count will be 3 or 4 depending on if alphaSize is bigger than 0.
channelSize will set the hueSize saturationSize and brightnessSize to the same value.
alphaUsage alphaPosition and typeInterpretation are all accessible with the accessors with the same name.
Definition at line 346 of file qpixelformat.h.
|
Constructor function making an RGB pixelformat.
redSize greenSize blueSize represent the size of each color channel. alphaSize describes the alpha channel size and its position is described with alphaPosition. alphaUsage is used to determine if the alpha channel is used or not. Setting the alpha channel size to 8 and alphaUsage to IgnoresAlpha is how it is possible to create a 32 bit format where the rgb channels only use 24 bits combined. premultiplied typeInterpretation are accessible with accessors with the same name.
Definition at line 254 of file qpixelformat.h.
|
Constructor function for creating a QPixelFormat describing a YUV format with yuvLayout.
alphaSize describes the size of a potential alpha channel and is position is described with alphaPosition. The "first" "second" .. "fifth" channels are all set to 0. alphaUsage premultiplied typeInterpretation and byteOrder will work as with other formats.
Definition at line 365 of file qpixelformat.h.