Pro.DIB — API for parsing DIB images

Overview

The Pro.DIB module contains the 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:

DIBCompression_ALPHABITFIELDS

Compression options: this value is valid in Windows CE .NET 4.0 and later.

DIBCompression_BITFIELDS

Compression options: pixel format defined by bit masks or Huffman 1D.

DIBCompression_JPEG

Compression options: the bitmap contains a JPEG image or RLE-24.

DIBCompression_PNG

Compression options: the bitmap contains a PNG image.

DIBCompression_RGB

Compression options: most common.

DIBCompression_RLE4

Compression options: can be used only with 4-bit/pixel bitmaps.

DIBCompression_RLE8

Compression options: can be used only with 8-bit/pixel bitmaps.

Classes:

DIBObject()

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_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:

BMPFormat

BMP image format.

DIBCursorFormat

DIB cursor image format.

DIBFormat

DIB image format.

DIBIconFormat

DIB icon image format.

Methods:

BMPHeader()

Returns the BMP header.

DIBHeader()

Returns the DIB header.

GetANDMaskRange()

Returns the range of the AND mask table if available; otherwise the returned Pro.Core.NTOffsetRange.offset is Pro.Core.INVALID_STREAM_OFFSET.

GetColorTableRange()

Returns the range of the color table if available; otherwise the returned Pro.Core.NTOffsetRange.offset is Pro.Core.INVALID_STREAM_OFFSET.

GetDIBFormat()

Returns the format of the DIB image (e.g., BMPFormat).

GetPixelArrayRange()

Returns the range of the pixel array.

HasANDMask()

Returns True if the image has an AND mask; otherwise returns False.

HasColorTable()

Returns True if the image has a color table; otherwise returns False.

IsBitmap()

Returns True if the DIB image format is a BMP; otherwise returns False.

IsDIBCoreHeader()

Returns True if the DIB header is minimalistic; otherwise returns False.

IsIcon()

Returns True if the DIB image format is either an icon or a cursor; otherwise returns False.

SetDIBFormat(format)

Sets the format of the DIB image.

BMPFormat: Final[int]

BMP image format.

See also GetDIBFormat() and SetDIBFormat().

BMPHeader()Pro.Core.CFFStruct
Returns

Returns the BMP header.

Return type

CFFStruct

See also DIBHeader().

DIBCursorFormat: Final[int]

DIB cursor image format.

See also GetDIBFormat() and SetDIBFormat().

DIBFormat: Final[int]

DIB image format.

See also GetDIBFormat() and SetDIBFormat().

DIBHeader()Pro.Core.CFFStruct
Returns

Returns the DIB header.

Return type

CFFStruct

DIBIconFormat: Final[int]

DIB icon image format.

See also GetDIBFormat() and SetDIBFormat().

GetANDMaskRange()Pro.Core.NTOffsetRange
Returns

Returns the range of the AND mask table if available; otherwise the returned Pro.Core.NTOffsetRange.offset is Pro.Core.INVALID_STREAM_OFFSET.

Return type

int

See also HasANDMask(), GetPixelArrayRange() and GetColorTableRange().

GetColorTableRange()Pro.Core.NTOffsetRange
Returns

Returns the range of the color table if available; otherwise the returned Pro.Core.NTOffsetRange.offset is Pro.Core.INVALID_STREAM_OFFSET.

Return type

int

See also HasColorTable(), GetPixelArrayRange() and GetANDMaskRange().

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() and GetANDMaskRange().

HasANDMask()bool
Returns

Returns True if the image has an AND mask; otherwise returns False.

Return type

bool

See also GetANDMaskRange().

HasColorTable()bool
Returns

Returns True if the image has a color table; otherwise returns False.

Return type

bool

See also GetColorTableRange().

IsBitmap()bool
Returns

Returns True if the DIB image format is a BMP; otherwise returns False.

Return type

bool

See also IsIcon().

IsDIBCoreHeader()bool
Returns

Returns True if the DIB header is minimalistic; otherwise returns False.

Return type

bool

See also DIBHeader().

IsIcon()bool
Returns

Returns True if the DIB image format is either an icon or a cursor; otherwise returns False.

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().