QPixelFormat¶
QPixelFormat
is a class for describing different pixel layouts in graphics buffers. More…
Synopsis¶
Functions¶
def
__eq__
(fmt2)def
__ne__
(fmt2)def
alphaPosition
()def
alphaSize
()def
alphaUsage
()def
bitsPerPixel
()def
blackSize
()def
blueSize
()def
brightnessSize
()def
byteOrder
()def
channelCount
()def
colorModel
()def
cyanSize
()def
greenSize
()def
hueSize
()def
lightnessSize
()def
magentaSize
()def
premultiplied
()def
redSize
()def
saturationSize
()def
subEnum
()def
typeInterpretation
()def
yellowSize
()def
yuvLayout
()
Detailed Description¶
In Qt there is a often a need to represent the layout of the pixels in a graphics buffer. Internally QPixelFormat
stores everything in a 64 bit datastructure. This gives performance but also some limitations.
QPixelFormat
can describe 5 color channels and 1 alpha channel, each can use 6 bits to describe the size of the color channel.
The position of the alpha channel is described with a separate enum. This is to make it possible to describe QImage
formats like ARGB32, and also describe typical OpenGL formats like RBGA8888.
How pixels are suppose to be read is determined by the TypeInterpretation
enum. It describes if color values are suppose to be read byte per byte, or if a pixel is suppose to be read as a complete int and then masked.
There is no support for describing YUV’s macro pixels. Instead a list of YUV formats has been made. When a QPixelFormat
is describing a YUV format, the bitsPerPixel
value has been deduced by the YUV Layout enum. Also, the color channels should all be set to zero except the fifth color channel that should store the bitsPerPixel
value.
See also
TypeInterpretation
- class PySide6.QtGui.QPixelFormat¶
PySide6.QtGui.QPixelFormat(colorModel, firstSize, secondSize, thirdSize, fourthSize, fifthSize, alphaSize, alphaUsage, alphaPosition, premultiplied, typeInterpretation[, byteOrder=QPixelFormat.ByteOrder.CurrentSystemEndian[, subEnum=0]])
PySide6.QtGui.QPixelFormat(QPixelFormat)
- Parameters
alphaPosition –
AlphaPosition
QPixelFormat –
PySide6.QtGui.QPixelFormat
firstSize – str
thirdSize – str
byteOrder –
ByteOrder
subEnum – str
fifthSize – str
fourthSize – str
colorModel –
ColorModel
alphaUsage –
AlphaUsage
typeInterpretation –
TypeInterpretation
secondSize – str
alphaSize – str
premultiplied –
AlphaPremultiplied
Creates a null pixelformat. This format maps to Format_Invalid
.
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
.
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.
- PySide6.QtGui.QPixelFormat.FieldWidth¶
- PySide6.QtGui.QPixelFormat.Field¶
- PySide6.QtGui.QPixelFormat.ColorModel¶
This enum type is used to describe the color model of the pixelformat. Alpha was added in 5.5.
Constant
Description
QPixelFormat.RGB
The color model is RGB.
QPixelFormat.BGR
This is logically the opposite endian version of RGB. However, for ease of use it has its own model.
QPixelFormat.Indexed
The color model uses a color palette.
QPixelFormat.Grayscale
The color model is Grayscale.
QPixelFormat.CMYK
The color model is CMYK.
QPixelFormat.HSL
The color model is HSL.
QPixelFormat.HSV
The color model is HSV.
QPixelFormat.YUV
The color model is YUV.
QPixelFormat.Alpha
There is no color model, only alpha is used.
- PySide6.QtGui.QPixelFormat.AlphaUsage¶
This enum describes if the alpha channel is used or not. Sometimes the pixelformat will have a size for the alpha channel, but the pixel format does actually not use the alpha channel. For example RGB32 is such a format. The RGB channels are 8 bits each, and there is no alpha channel. But the complete size for each pixel is 32. Therefore the alpha channel size is 8, but the alpha channel is ignored. Its important to note that in such situations the position of the alpha channel is significant.
Constant
Description
QPixelFormat.IgnoresAlpha
The alpha channel is not used.
QPixelFormat.UsesAlpha
The alpha channel is used.
- PySide6.QtGui.QPixelFormat.AlphaPosition¶
This enum type is used to describe the alpha channels position relative to the color channels.
Constant
Description
QPixelFormat.AtBeginning
The alpha channel will be put in front of the color channels . E.g. ARGB.
QPixelFormat.AtEnd
The alpha channel will be put in the back of the color channels. E.g. RGBA.
- PySide6.QtGui.QPixelFormat.AlphaPremultiplied¶
This enum type describes the boolean state if the alpha channel is multiplied into the color channels or not.
Constant
Description
QPixelFormat.NotPremultiplied
The alpha channel is not multiplied into the color channels.
QPixelFormat.Premultiplied
The alpha channel is multiplied into the color channels.
- PySide6.QtGui.QPixelFormat.TypeInterpretation¶
This enum describes how each pixel is interpreted. If a pixel is read as a full 32 bit unsigned integer and then each channel is masked out, or if each byte is read as unsigned char values. Typically QImage
formats interpret one pixel as an unsigned integer and then the color channels are masked out. OpenGL on the other hand typically interpreted pixels “one byte after the other”, Ie. unsigned byte.
QImage
also have the format Format_RGBA8888 (and its derivatives), where the pixels are interpreted as unsigned bytes. OpenGL has extensions that makes it possible to upload pixel buffers in an unsigned integer format.
The image above shows a ARGB pixel in memory read as an unsigned integer. However, if this pixel was read byte for byte on a little endian system the first byte would be the byte containing the B-channel. The next byte would be the G-channel, then the R-channel and finally the A-channel. This shows that on little endian systems, how each pixel is interpreted is significant for integer formats. This is not the case on big endian systems.
Constant
Description
QPixelFormat.UnsignedInteger
QPixelFormat.UnsignedShort
QPixelFormat.UnsignedByte
QPixelFormat.FloatingPoint
- PySide6.QtGui.QPixelFormat.YUVLayout¶
YUV is not represented by describing the size of the color channels. This is because YUV often use macro pixels, making the concept of separate color channels invalid. Instead the different YUV layouts are described with this enum.
Constant
Description
QPixelFormat.YUV444
QPixelFormat.YUV422
QPixelFormat.YUV411
QPixelFormat.YUV420P
QPixelFormat.YUV420SP
QPixelFormat.YV12
QPixelFormat.UYVY
QPixelFormat.YUYV
QPixelFormat.NV12
QPixelFormat.NV21
QPixelFormat.IMC1
QPixelFormat.IMC2
QPixelFormat.IMC3
QPixelFormat.IMC4
QPixelFormat.Y8
QPixelFormat.Y16
- PySide6.QtGui.QPixelFormat.ByteOrder¶
This enum describes the of the pixel format. This enum is mostly ignored but have some use cases for YUV formats. BGR formats have their own color model, and should not be described by using the opposite endianness on an RGB format.
Constant
Description
QPixelFormat.LittleEndian
The byte order is little endian.
QPixelFormat.BigEndian
The byte order is big endian.
QPixelFormat.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.
- PySide6.QtGui.QPixelFormat.alphaPosition()¶
- Return type
Accessor function for .
- PySide6.QtGui.QPixelFormat.alphaSize()¶
- Return type
str
Accessor function for the alpha channel size.
- PySide6.QtGui.QPixelFormat.alphaUsage()¶
- Return type
Accessor function for .
- PySide6.QtGui.QPixelFormat.bitsPerPixel()¶
- Return type
str
Accessor function for the bits used per pixel. This function returns the sum of the color channels + the size of the alpha channel.
- PySide6.QtGui.QPixelFormat.blackSize()¶
- Return type
str
Accessor function for the black/key color channel.
- PySide6.QtGui.QPixelFormat.blueSize()¶
- Return type
str
Accessor function for the size of the blue color channel.
- PySide6.QtGui.QPixelFormat.brightnessSize()¶
- Return type
str
Accessor function for the brightness channel size.
The byte order is almost always set the byte order of the current system. However, it can be useful to describe some YUV formats. This function should never return CurrentSystemEndian
as this value is translated to a endian value in the constructor.
- PySide6.QtGui.QPixelFormat.channelCount()¶
- Return type
str
Accessor function for getting the . Channel Count is deduced by color channels with a size > 0 and if the size of the alpha channel is > 0.
- PySide6.QtGui.QPixelFormat.colorModel()¶
- Return type
Accessor function for getting the .
- PySide6.QtGui.QPixelFormat.cyanSize()¶
- Return type
str
Accessor function for the cyan color channel.
- PySide6.QtGui.QPixelFormat.greenSize()¶
- Return type
str
Accessor function for the size of the green color channel.
- PySide6.QtGui.QPixelFormat.hueSize()¶
- Return type
str
Accessor function for the hue channel size.
- PySide6.QtGui.QPixelFormat.lightnessSize()¶
- Return type
str
Accessor function for the lightness channel size.
- PySide6.QtGui.QPixelFormat.magentaSize()¶
- Return type
str
Accessor function for the megenta color channel.
- PySide6.QtGui.QPixelFormat.__ne__(fmt2)¶
- Parameters
fmt2 –
PySide6.QtGui.QPixelFormat
- Return type
bool
- PySide6.QtGui.QPixelFormat.__eq__(fmt2)¶
- Parameters
fmt2 –
PySide6.QtGui.QPixelFormat
- Return type
bool
- PySide6.QtGui.QPixelFormat.premultiplied()¶
- Return type
Accessor function for the AlphaPremultiplied
enum. This indicates if the alpha channel is multiplied in to the color channels.
- PySide6.QtGui.QPixelFormat.redSize()¶
- Return type
str
Accessor function for the size of the red color channel.
- PySide6.QtGui.QPixelFormat.saturationSize()¶
- Return type
str
Accessor function for the saturation channel size.
- PySide6.QtGui.QPixelFormat.subEnum()¶
- Return type
str
- PySide6.QtGui.QPixelFormat.typeInterpretation()¶
- Return type
Accessor function for the type representation of a color channel or a pixel.
See also
TypeInterpretation
- PySide6.QtGui.QPixelFormat.yellowSize()¶
- Return type
str
Accessor function for the yellow color channel.
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.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.