Definitions of several special types (including Raw Image) to be used for graphics.

graphtype.pp contains graphic-related platform-independent types and utility functions.

This file is part of the LazUtils package.

Defines the Integer range type with values that can be used for colors.
TColor
Indicates how a surface area is filled with a given color.

Used in widgetset classes to implement the FloodFill routine and method.

TFillStyle
Fills an area where the pixels have the specified color. Fill color is applied in all directions to pixels with the specified color. Used to fill an area with multiple colors at its boundaries.
Fills an area bounded by the specified color. Like the Windows FloodFill routine.
Represents bevel drawing styles.
The bevel is not drawn.
The bevel is drawn with a lowered or inset appearance.
The bevel is drawn with a raised or outset appearance.
The bevel is drawn as a space using the required width, netiher inset nor outset.
Represents drawing effects which can be applied to graphic elements.
No drawing effect.
Drawn with a grayed image.
Drawn with a highlighted image.
Drawn with a shadowed image.
1-Bit image (for non-XP windows buttons).
Color format for raw image data.

Color format for raw image data. A raw image can contain RGBA or monochrome pixels.

Higher values means higher intensity. For example: Red=0 means no Red, Alpha=0 means transparent.

ricfNone indicates an uninitialized image.
Each pixel contains red, green, blue and alpha values. If AlphaPrec=0 then there is no alpha channel. Same for RedPrec, GreenPrec and BluePrec.
Red, Green, and Blue have the same values. Red stores the Gray. AlphaPrec can be >0.
The LSB/MSB-first byte order of pixel data.
Least Significant Byte first.
Most SignificantBbyte first.
Bit order for raw image data scan lines.
The first pixel in a raw image line can be the left or right pixel of the displayed image.
Bit 0 represents first pixel.
Bit 0 represents highest pixel.
The alignment of raw image scanlines.
No gap at the end of Scanlines; Scanlines can begin inside a byte boundary.
Scanlines start on a byte boundary.
Scanlines start at a 16-bit boundary.
Scanlines start at a 32-bit (DWORD) boundary.
Scanlines start at a 64-bit (QWORD) boundary.
Scanlines start at a 128-bit boundary.
The first stored line of pixels can represent the logical top or bottom of the displayed image.
First scanline at the top.
First scanline at the bottom.
Image formats supported by a device, or present in image data.
Include a description for a mono image.
Include a description for a grey image.
Include a description for an RGB image.
Include a description for an Alpha channel.
Include a description for a Mask.
Include a description for a Palette.
Update given description (instead of clearing it).
Set type used to store values from the TRawImageQueryFlag enumeration.

Passed as an argument to routines in the LCL interface an widgetset classes. Used to determine when the image descriptor for raw image data needs to be read from its device context or handle.

Descriptor object for the image format of devices and raw (uncompressed) image data.

This effectively is a record with some attached methods. More related procedures exist outside the object.

The object describes the presence and exact storage of the RGBA image and mask pixels, of a device or image. The color information is stored in aligned scanlines.

Note: palettes, BitOrder and ByteOrder seem not to be implemented yet. The meaning of the PaletteXXX values and of BitOrder is undefined, so far.

xxxBitsPerPixel and xxxPrecisionMask applies to color data. For masked images, the pixels and the mask are two different arrays, containing different elements.

An initialized image can contain color (RGBA) or monochrome pixels.
ricfNone
indicates an uninitialized image.
Width of the image in pixels.
Height of the image in pixels.
Number of bits used per pixel.
The color and pixel storage can be subject to alignment, so that the logical color Depth can be less than the physical BitsPerPixel.
Indicates the bit order for scanlines in the raw image data.
The LSB/MSB-first byte order for color data.
The first stored line of pixels can represent the logical top or bottom of the displayed image.
Alignment of the scanlines.
Number of bits stored per pixel.
BitsPerPixel
can be greater than the logical (used) Depth.
Bits per pixel in the Red channel.
Bit offset of the Red channel in color data.
Bits per pixel in the Green channel.
Bit offset of the Green channel in color data.
Bits per pixel in the Blue channel.
Bit offset of the Blue channel in color data.
Bits per pixel in the Alpha channel.
Bit offset of the Alpha channel in color data.
Bits per mask pixel, usually 1, 0 when no mask.

Mask-related properties are only valid if there is a mask (MaskBitsPerPixel > 0).

A pixel Mask currently has a logical depth of 1 bit per pixel, but a pixel can occupy an entire byte. As opposed to the Alpha (transparency) channel, a Mask is stored in its own array. A Mask value of 1 means that the pixel is masked (transparent); a value of 0 means the pixel value is shown (opaque).

The bit offset of the mask bit.
Alignment of Mask lines.
Bit order of the Mask.
Entries in the color palette, 0 when no palette.

Palette-related properties are only valid if there is a palette (PaletteColorCount > 0).

Bits per palette index, stored in the pixel data.

When a palette is used, the color description fields apply to the palette colors, while pixel data contains the palette index. Then Depth applies to the size of the palette colors, and the pixel data is described by PaletteBitsPerIndex and PaletteShift.

[ palettes are not yet implemented ]
Bit shift direction from least to most significant.
Indicates the alignment or padding used at the end of a scanline in the raw image data.

Valid when PaletteColorCount has a positive non-zero value.

Bit order of the palette indices.
Byte order of the palette indices.
Initialize the image descriptor to all zeroes.

A constructor cannot be used here, it would break compatibility with a record.

1-bit mono format.
16-bit format.
24-bit format with bits in RGB order from top to bottom.
24-bit format with bits in RGB order from bottom to top.
32-bit format with an Alpha channel, bits in RGB order from top to bottom.
32-bit format with bits in RGB order plus an Alpha channel, ordered from top to bottom.
Init for an unmasked 24 bit RGB image (LSB Blue).

Init_BPP24_B8G8R8_BIO_TTB - initiator for specified format

{ pf24bit: Format=ricfRGBA HasPalette=false Depth=24 PaletteColorCount=0 BitOrder=riboBitsInOrder ByteOrder=DefaultByteOrder LineOrder=riloTopToBottom BitsPerPixel=24 LineEnd=rileDWordBoundary RedPrec=8 RedShift=16 GreenPrec=8 GreenShift=8 BluePrec=8 BlueShift=0 }
Init for a masked 24 bit RGB image (LSB Blue).

Init_BPP24_B8G8R8_M1_BIO_TTB - initiator for specified format

{ pf24bit: Format=ricfRGBA HasPalette=false Depth=24 PaletteColorCount=0 BitOrder=riboBitsInOrder ByteOrder=DefaultByteOrder LineOrder=riloTopToBottom BitsPerPixel=24 LineEnd=rileDWordBoundary RedPrec=8 RedShift=16 GreenPrec=8 GreenShift=8 BluePrec=8 BlueShift=0 Masked }
Init for an unmasked 32 bit RGB image (LSB blue).

Init_BPP32_B8G8R8_BIO_TTB - initiator for specified format

{ pf32bit: Format=ricfRGBA HasPalette=false Depth=24 PaletteColorCount=0 BitOrder=riboBitsInOrder ByteOrder=DefaultByteOrder LineOrder=riloTopToBottom BitsPerPixel=32 LineEnd=rileDWordBoundary RedPrec=8 RedShift=16 GreenPrec=8 GreenShift=8 BluePrec=8 BlueShift=0 No alpha No mask }
Init for a masked 32 bit RGB image (LSB blue).

Init_BPP32_B8G8R8_M1_BIO_TTB - initiator for specified format

{ pf32bit: Format=ricfRGBA HasPalette=false Depth=24 PaletteColorCount=0 BitOrder=riboBitsInOrder ByteOrder=DefaultByteOrder LineOrder=riloTopToBottom BitsPerPixel=32 LineEnd=rileDWordBoundary RedPrec=8 RedShift=16 GreenPrec=8 GreenShift=8 BluePrec=8 BlueShift=0 no alpha with mask }
Init for an unmasked 32 bit RGBA image (LSB blue).

Init_BPP32_B8G8R8A8_BIO_TTB - initiator for specified format

{ pf32bit: Format=ricfRGBA HasPalette=false Depth=32 PaletteColorCount=0 BitOrder=riboBitsInOrder ByteOrder=DefaultByteOrder LineOrder=riloTopToBottom BitsPerPixel=32 LineEnd=rileDWordBoundary RedPrec=8 RedShift=16 GreenPrec=8 GreenShift=8 BluePrec=8 BlueShift=0 alpha no mask }
Init for a masked 32 bit RGBA image (LSB blue).

Init_BPP32_B8G8R8A8_M1_BIO_TTB - initiator for specified format

{ pf32bit: Format=ricfRGBA HasPalette=false Depth=32 PaletteColorCount=0 BitOrder=riboBitsInOrder ByteOrder=DefaultByteOrder LineOrder=riloTopToBottom BitsPerPixel=32 LineEnd=rileDWordBoundary RedPrec=8 RedShift=16 GreenPrec=8 GreenShift=8 BluePrec=8 BlueShift=0 alpha masked }
Returns an monochrome image descriptor constructed from the Mask.
Returns an monochrome image descriptor constructed from the Alpha channel.
Gets the indices of channels in four-element array.
The number of bytes per scanline.
The number of bits per scanline.
The number of bytes per Mask scanline.
The number of bits per Mask scanline.
The image descriptor as a string.
Compares with the given description, returns True if it is equal.
Pointer to
Record describing a position in Raw Image data.
Byte is the byte offset, Bit the bit number/offset in that byte.
PRawImagePosition
- pointer to a TRawImagePosition.
An uncompressed graphics image (bitmap).

This object hold the pixels, mask and color palette of the image, as well as a detailed description of the storage format of these parts.

This object currently is subject to refactoring, don't use it in application code.

Description
record for the Raw Image.
Data
- a pointer to the actual data of the image.
DataSize
- pointer to the size of the image.
Mask
- pointer to the Mask for use with the image.
MaskSize
- pointer to the size of the mask.
Palette
- pointer to the palette of colors for this image.
PaletteSize
- pointer to the size of the palette.
Init
- initiator for the object. Don't use a constructor here, it will break compatibility with a record.
CreateData
- method to create the data for the record.
Destroys the allocated Data, Mask and Palette arrays.
ReleaseData
- frees the resources when finished with the data.
ExtractRect
- find the position of the bounding rectangle from the raw data.
Gets a pointer to the byte position at the beginning of the specified scanline.

The return value is Nil if Data has not been assigned in the class instance, and when the ALine argument contains 0 (zero). The pointer position is calculated as the product of ALine and the BytesPerLine setting in the image Description.

PerformEffect
- applies a specified special effect to the data of the Raw Image.
ReadBits
- reads the bit values for the raw image data at a given position.
Reads the Red, Green, Blue and Alpha channel values at a given position in pixel data.
Reads the Mask value at the given position in the image data.
Reads the Mask value at the given position in the image data. Returns AMask=True if the pixel is transparent. The position in the Mask data typically differs from the position in the color data.
Writes ABits into Data at the given position.
WriteChannels
- writes the specified channel values at the nominated position.
Writes the mask for the raw image when assigned and given a valid bit depth in the image description.
IsMasked
- returns True if the specified pixels are masked.
IsTransparent
- returns True if the specified pixels are transparent.
IsEqual
- returns True if the current and specified images are equal.
PRawImage
- pointer to a TRawImage.
TRawImageLineStarts
- contains a list of the start positions of the lines in the Raw Image.
The array of start positions for scanlines in a raw image.
Init
- initiator for the object. Don't use a constructor here, it will break compatibility with a record.
GetPosition
- returns the position specified by x, y coordinates as a TRawImagePosition.
PRawImageLineStarts
- pointer to TRawImageLineStarts.
Byte order for raw image data on the platform or widgetset.
Value from TRawImageByteOrder with the byte order (Endian-ness) for the platform or widgetset
GetBytesPerLine
- returns the number of bytes per line (as a pointer).
GetBitsPerLine
- returns the number of bits per line (as a pointer).
CopyImageData
- copies data from ASource to ADestination, returning True if successful.
Converts the specified set of raw image query flags to a String value.
Used to pad bit data in a raw image to specific precisions and byte boundaries.
Used to pad bit data in a raw image to specific precisions and byte boundaries.