Pro.DIB
— API for parsing DIB images¶
Parsing a BMP image¶
The following code example demonstrates how to parse bitmap:
from Pro.Core import *
from Pro.DIB import *
def parseBitmap(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = DIBObject()
obj.SetDIBFormat(DIBObject.BMPFormat)
if not obj.Load(c):
return
hdr = obj.DIBHeader()
print("Width:", hdr.Num("Width"), "Height:", hdr.Num("Height"))
Module API¶
Pro.DIB module API.
Attributes:
Compression options: this value is valid in Windows CE .NET 4.0 and later.
Compression options: pixel format defined by bit masks or Huffman 1D.
Compression options: no compression with CMYK color space: used for uncompressed CMYK bitmaps.
Compression options: 4-bit RLE compression with CMYK color space: used for RLE compressed CMYK bitmaps.
Compression options: 8-bit RLE compression with CMYK color space: used for RLE compressed CMYK bitmaps.
Compression options: the bitmap contains a JPEG image or RLE-24.
Compression options: the bitmap contains a PNG image.
Compression options: most common.
Compression options: can be used only with 4-bit/pixel bitmaps.
Compression options: can be used only with 8-bit/pixel bitmaps.
Classes:
This class represents a DIB image.
- DIBCompression_ALPHABITFIELDS: Final[int]¶
Compression options: this value is valid in Windows CE .NET 4.0 and later.
See also
DIBObject.DIBHeader()
.
- DIBCompression_BITFIELDS: Final[int]¶
Compression options: pixel format defined by bit masks or Huffman 1D.
See also
DIBObject.DIBHeader()
.
- DIBCompression_CMYK: Final[int]¶
Compression options: no compression with CMYK color space: used for uncompressed CMYK bitmaps.
See also
DIBObject.DIBHeader()
.
- DIBCompression_CMYKRLE4: Final[int]¶
Compression options: 4-bit RLE compression with CMYK color space: used for RLE compressed CMYK bitmaps.
See also
DIBObject.DIBHeader()
.
- DIBCompression_CMYKRLE8: Final[int]¶
Compression options: 8-bit RLE compression with CMYK color space: used for RLE compressed CMYK bitmaps.
See also
DIBObject.DIBHeader()
.
- DIBCompression_JPEG: Final[int]¶
Compression options: the bitmap contains a JPEG image or RLE-24.
See also
DIBObject.DIBHeader()
.
- DIBCompression_PNG: Final[int]¶
Compression options: the bitmap contains a PNG image.
See also
DIBObject.DIBHeader()
.
- DIBCompression_RGB: Final[int]¶
Compression options: most common.
See also
DIBObject.DIBHeader()
.
- DIBCompression_RLE4: Final[int]¶
Compression options: can be used only with 4-bit/pixel bitmaps.
See also
DIBObject.DIBHeader()
.
- DIBCompression_RLE8: Final[int]¶
Compression options: can be used only with 8-bit/pixel bitmaps.
See also
DIBObject.DIBHeader()
.
- class DIBObject¶
Bases:
Pro.Core.CFFObject
This class represents a DIB image.
Attributes:
BMP image format.
DIB cursor image format.
DIB image format.
DIB icon image format.
Methods:
Returns the BMP header.
Returns the DIB header.
Returns the range of the AND mask table if available; otherwise the returned
Pro.Core.NTOffsetRange.offset
isPro.Core.INVALID_STREAM_OFFSET
.Returns the range of the color table if available; otherwise the returned
Pro.Core.NTOffsetRange.offset
isPro.Core.INVALID_STREAM_OFFSET
.Returns the format of the DIB image (e.g.,
BMPFormat
).Returns the range of the pixel array.
Returns
True
if the image has an AND mask; otherwise returnsFalse
.Returns
True
if the image has a color table; otherwise returnsFalse
.
IsBitmap
()Returns
True
if the DIB image format is a BMP; otherwise returnsFalse
.Returns
True
if the DIB header is minimalistic; otherwise returnsFalse
.
IsIcon
()Returns
True
if the DIB image format is either an icon or a cursor; otherwise returnsFalse
.
SetDIBFormat
(format)Sets the format of the DIB image.
- BMPFormat: Final[int]¶
BMP image format.
See also
GetDIBFormat()
andSetDIBFormat()
.
- BMPHeader() → Pro.Core.CFFStruct¶
- Returns
Returns the BMP header.
- Return type
See also
DIBHeader()
.
- DIBCursorFormat: Final[int]¶
DIB cursor image format.
See also
GetDIBFormat()
andSetDIBFormat()
.
- DIBFormat: Final[int]¶
DIB image format.
See also
GetDIBFormat()
andSetDIBFormat()
.
- DIBHeader() → Pro.Core.CFFStruct¶
- Returns
Returns the DIB header.
- Return type
- DIBIconFormat: Final[int]¶
DIB icon image format.
See also
GetDIBFormat()
andSetDIBFormat()
.
- GetANDMaskRange() → Pro.Core.NTOffsetRange¶
- Returns
Returns the range of the AND mask table if available; otherwise the returned
Pro.Core.NTOffsetRange.offset
isPro.Core.INVALID_STREAM_OFFSET
.- Return type
int
See also
HasANDMask()
,GetPixelArrayRange()
andGetColorTableRange()
.
- GetColorTableRange() → Pro.Core.NTOffsetRange¶
- Returns
Returns the range of the color table if available; otherwise the returned
Pro.Core.NTOffsetRange.offset
isPro.Core.INVALID_STREAM_OFFSET
.- Return type
int
See also
HasColorTable()
,GetPixelArrayRange()
andGetANDMaskRange()
.
- GetDIBFormat() → int¶
- Returns
Returns the format of the DIB image (e.g.,
BMPFormat
).- Return type
int
See also
SetDIBFormat()
.
- GetPixelArrayRange() → Pro.Core.NTOffsetRange¶
- Returns
Returns the range of the pixel array.
- Return type
int
See also
GetColorTableRange()
andGetANDMaskRange()
.
- HasANDMask() → bool¶
- Returns
Returns
True
if the image has an AND mask; otherwise returnsFalse
.- Return type
bool
See also
GetANDMaskRange()
.
- HasColorTable() → bool¶
- Returns
Returns
True
if the image has a color table; otherwise returnsFalse
.- Return type
bool
See also
GetColorTableRange()
.
- IsBitmap() → bool¶
- Returns
Returns
True
if the DIB image format is a BMP; otherwise returnsFalse
.- Return type
bool
See also
IsIcon()
.
- IsDIBCoreHeader() → bool¶
- Returns
Returns
True
if the DIB header is minimalistic; otherwise returnsFalse
.- Return type
bool
See also
DIBHeader()
.
- IsIcon() → bool¶
- Returns
Returns
True
if the DIB image format is either an icon or a cursor; otherwise returnsFalse
.- Return type
bool
See also
IsBitmap()
.
- SetDIBFormat(format: int) → None¶
Sets the format of the DIB image.
Important
This method must be called before
Pro.Core.CFFObject.Load()
.
- Parameters
format (int) – The format of the DIB image (e.g.,
BMPFormat
).See also
GetDIBFormat()
.