Classes and functions for easy handling of raw images (interface images).

Author: Mattias Gaertner

Represents a graphical image.

TLazIntfImage is a TFPCustomImage descendant which stores the image data as TRawImage, and is therefore able to interchange images directly with the LCL interfaces.

A large number of the protected methods (GetColorxxxxxx and SetColorxxxxxx) deal with direct interface to the operating system at the pixel level.

Usage examples:

1. Loading an .xpm file into a TBitmap:

var BmpHnd,MaskHnd: HBitmap; Bitmap1: TBitmap; IntfImg1: TLazIntfImage; Reader: TLazReaderXPM; begin // create a bitmap (or use an existing one) Bitmap1:=TBitmap.Create; // create the raw image IntfImg1:=TLazIntfImage.Create(0,0); // get the description for the current screen (bitsperpixel, depth, ...) IntfImg1.GetDescriptionFromDevice(0); // create the XPM reader Reader:=TLazReaderXPM.Create; // load the image IntfImg1.LoadFromFile('filename.xpm',Reader); // create the bitmap handles IntfImg1.CreateBitmap(BmpHnd,MaskHnd); // apply handles to the Bitmap1 Bitmap1.Handle:=BmpHnd; Bitmap1.MaskHandle:=MaskHnd; // clean up Reader.Free; IntfImg1.Free; // do something with the Bitmap1 ... end;

2. Saving a TBitmap to an .xpm file:

var BmpHnd,MaskHnd: HBitmap; Bitmap1: TBitmap; IntfImg1: TLazIntfImage; Writer: TLazWriterXPM; begin ... // create the raw image IntfImg1:=TLazIntfImage.Create(0,0); // load the raw image from the bitmap handles IntfImg1.LoadFromBitmap(Bitmap1.Handle,Bitmap1.MaskHandle); // create the XPM writer Writer:=TLazWriterXPM.Create; // save image to file IntfImg1.SaveToFile('filename.xpm',Writer); // clean up Writer.Free; IntfImg1.Free; ... end; }
Constructor for the class instance. Alternate constructor for the class instance. Destructor for the class instance. Stores values from the specified persistent object into the current class instance. Increments the internal update counter. Decrements the internal update counter. SetSize - define the height and width of the image. CheckDescription - looks at the supplied Image Description record and returns True if it matches the actual properties of the image. Generates an exception if an error is encountered in the image description LoadFromDevice - loads the image from the device with specified handle. LoadFromBitmap - loads the image from a Bitmap. CreateBitmaps - generates a Bitmap and an optional Mask for the image data. Stores the raw image data in the class instance. Gets the raw image data stored in the class instance and optionally release ownership. Sets the color for all pixels in the raw image data to the specified value. Merges a source image with alpha blending.

Merges an image to a canvas using alpha blending according to a separate image containing the alpha channel. White pixels in the alpha channel will correspond to the source image pixel being fully drawn, grey ones are merged and black ones ignored.

If ASourceAlpha is Nil then it will utilize the alpha channel from ASource.

Gets the alpha value from the mask if needed.

AlphaFromMask gets the alpha value from the mask if AKeepAlpha is True (default condition).

GetXYDataPosition - finds the position of the raw image. Yes, it really is spelled 'Postion' GetXYMaskPostion - finds the position of the raw image mask. Returns an pointer to the raw data for a scan line.

Similar to Delphi's TBitmap.ScanLine. Works with scan lines aligned to whole bytes.

PixelData - the raw image data for the image. MaskData - the raw data for the mask in the image. DataDescription - the raw description record for the current image. TColors - the colors available for the specified pixel. Masked - whether the image mask applies at the specified position. TLazIntfImageMask - applying a mask at the Raw Image level. Image - the image to which masking is applied. Descendant of TFPPalette which uses an AVL tree for speed up. Destructor for the class instance. Constructor for the class instance. Destructor for the class instance. Constructor for the class instance. Destructor for the class instance.

ILazImageReader is an interface used to extend TFPCustomImageReader to initialize a TRawImgeDescription based on the image to be read.

TLazReaderXPM - this is a FPImage reader for xpm images. Constructor for the class instance. Destructor for the class instance. TLazWriterXPM is a FPImage writer for xpm images. Constructor for the class instance. No mask is generated. A mask is generated based on the first pixel read.

Note: when reading images with an alpha channel and the alpha channel has no influence on the mask (the maskcolor is transparent).

A mask is generated based on the given color.

Note: when reading images with an alpha channel and the alpha channel has no influence on the mask (the maskcolor is transparent).

For completeness - don't know if they exist. For completeness - don't know if they exist. For completeness - don't know if they exist. Color which should be interpreted as masked. For palette based images, index of the color which should be interpreted as masked. Size (in bytes) for a scanline. Information about the bitmap as read from the stream. Buffer with Palette entries. Buffer for ascanline. Can be Byte, Word, TColorRGB or TColorRGBA. If set, rawimagedescription is updated. For progress support. If alpha channel is declared but does not exist (all values = 0). Required by TFPCustomImageReader. Constructor for the class instance. Destructor for the class instance. TLazReaderBMP - This is an improved FPImage reader for bmp images. Some bitmaps can specify the data offset. Implements an image reader for a single DIB in an icon file.

TLazReaderIconDIB is a FPImage reader for a single DIB from an icon file.

Extends the FCL TIFF image reader to support the ILazImageReader interface.

Defined for LCL versions prior to 2.06.01, where the OnCreateImage event is "abused" to update the description after the format and before the image is read.

Extends the FCL TIFF image writer to support the ILazImageWriter interface. Constructor for the class instance.

Create is the overridden constructor for the class instance, and calls the inherited constructor on entry. Create initializes members in the class instance, and sets the default value for IconType to iitNone.

Destructor for the class instance.

Destroy is the overridden destructor for the class instance. Destroy frees resources allocated for members, and calls the inherited destructor prior to exit.