[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TRasterImage

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

TRasterImage - base class for a number of graphic controls, including TCustomBitmap and TCustomIcon, which use a raster of dots to display graphic information.

## Declaration

Source position: graphics.pp line 1240

`type TRasterImage = class(TGraphic)`
`protected`
`FSharedImage: TSharedRasterImage;` |  | Shared image with existing handles, canvases, etc.
`function CanShareImage(); virtual;` |  | CanShareImage - returns True if specified class of image can be shared.
`procedure Changed(); override;` |  | Changed - method to call when properties have changed.
`function CreateDefaultBitmapHandle(); virtual;` |  | Gets the default value for the Bitmap handle used in the class instance.
`procedure Draw(); override;` |  | Renders the image to the specified canvas.
`function GetEmpty; override;` |  | Gets the value for the Empty property.
`function GetHandle;` |  | Gets the value for the handle used in the image.
`function GetBitmapHandle; virtual; abstract;` |  | Gets the value for the BitmapHandle property.
`function GetMasked; virtual;` |  | Gets the value for the Masked property.
`function GetMaskHandle; virtual; abstract;` |  | Gets the value for the MaskHandle property.
`function GetMimeType; override;` |  | Gets the value for the MimeType property.
`function GetPixelFormat; virtual; abstract;` |  | GetPixelFormat - returns the pixel format for the Image.
`function GetRawImagePtr; virtual; abstract;` |  | Gets a pointer with the raw image data.
`function GetRawImageDescriptionPtr; virtual; abstract;` |  | Gets a pointer to the metadata for the raw image data.
`function GetTransparent; override;` |  | Gets the value for the Transparent property.
`class function GetSharedImageClass; virtual;` |  | Gets the class reference used to create new shared image instances in the class.
`function GetHeight; override;` |  | Gets the value for the Height property.
`function GetWidth; override;` |  | Gets the value for the Width property.
`procedure BitmapHandleNeeded; virtual;` |  | Ensures that handles for the image and mask are valid for the raw image data.
`procedure HandleNeeded; virtual; abstract;` |  | Ensures that a handle for the image is allocated in widgetset classes.
`procedure MaskHandleNeeded; virtual; abstract;` |  | Ensures that a handle is allocated for the image mask (when needed).
`procedure PaletteNeeded; virtual; abstract;` |  | Ensures that a handle for the palette is allocated.
`function InternalReleaseBitmapHandle; virtual; abstract;` |  | InternalReleaseBitmapHandle - releases Bitmap Handle and returns its value.
`function InternalReleaseMaskHandle; virtual; abstract;` |  | InternalReleaseMaskHandle - releases Mask Handle and returns its value.
`function InternalReleasePalette; virtual; abstract;` |  | InternalReleasePalette - releases Palette Handle and returns its value.
`procedure SetBitmapHandle();` |  | Sets the value for the BitmapHandle property.
`procedure SetMasked(); virtual;` |  | Sets the value for the Masked property.
`procedure SetMaskHandle();` |  | Sets the value for the MaskHandle property.
`procedure SetTransparent(); override;` |  | Sets the value for the Transparent property.
`procedure UnshareImage(); virtual; abstract;` |  | Unshares a shared image when its handle is changed or the save stream is freed.
`function UpdateHandles(); virtual; abstract;` |  | Updates image handles when the raw image data is loaded.
`procedure SaveStreamNeeded;` |  | Ensures that the save stream for the shared image is allocated.
`procedure FreeSaveStream;` |  | Frees the save stream assigned to the internal shared image.
`procedure ReadData(); override;` |  | Reads image data during component streaming.
`procedure ReadStream(); virtual; abstract;` |  | ReadStream - loads image data into the raw image.
`procedure SetSize(); virtual; abstract;` |  | SetSize - specifies height and width of Image.
`procedure SetHandle(); virtual;` |  | Sets the handle used for the image.
`procedure SetHeight(); override;` |  | Sets the value for the Height property.
`procedure SetWidth(); override;` |  | Sets the value for the Width property.
`procedure SetTransparentMode();` |  | Sets the value for the TransparentMode property.
`procedure SetPixelFormat(); virtual; abstract;` |  | Sets the value for the PixelFormat property.
`procedure WriteData(); override;` |  | Writes raw image data to the specified stream.
`procedure WriteStream(); virtual; abstract;` |  | Writes the image content to the specified stream instance.
`function RequestTransparentColor;` |  | Gets the color used to represent transparent pixels in the image.
`public`
`constructor Create; override;` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destroy is the destructor for TRasterImage: frees the canvas, and releases image then calls inherited Destroy.
`procedure Assign(); override;` |  | Assign - copies details from Source according to data type.
`procedure Clear; override;` |  | Removes raw image data and frees the internal save stream.
`procedure BeginUpdate();` |  | BeginUpdate - start the update process.
`procedure EndUpdate();` |  | EndUpdate - finishes the update process.
`procedure FreeImage; virtual;` |  | Frees the image by resetting its handle.
`function BitmapHandleAllocated; virtual; abstract;` |  | BitmapHandleAllocated - returns True if a handle has been allocated for the Bitmap.
`function MaskHandleAllocated; virtual; abstract;` |  | MaskHandleAllocated - returns True if a handle has been allocated for the Mask.
`function PaletteAllocated; virtual; abstract;` |  | PaletteAllocated - returns True if a Palette has been allocated.
`procedure LoadFromBitmapHandles();` |  | Loads the image data from the specified Bitmap and Mask handles.
`procedure LoadFromDevice(); virtual;` |  | Loads image data from the specified device context.
`procedure LoadFromStream();` |  | LoadFromStream - loads data for the image from a specified data stream, optionally supplying its size.
`procedure LoadFromMimeStream(); override;` |  | Loads image data from a stream for the specified MIME type.
`procedure LoadFromRawImage();` |  | Loads image data from the specified TRawImage instance.
`procedure LoadFromIntfImage();` |  | Loads the image from a TLazIntfImage instance.
`procedure SaveToStream(); override;` |  | Saves image data to the specified stream.
`procedure GetSupportedSourceMimeTypes(); override;` |  | Gets a list of supported MIME types for image data used in the image type.
`procedure GetSize();` |  | Gets the image Width and Height from the metadata for the raw image.
`procedure Mask();` |  | Applies the color used for transparent pixels to the image.
`procedure SetHandles(); virtual; abstract;` |  | Sets handles for the bitmap and the mask to the specified values.
`function ReleaseBitmapHandle;` |  | Releases the handle in the shared image without freeing the BitmapHandle.
`function ReleaseMaskHandle;` |  | ReleaseMaskHandle - releases the Handle used for the Mask.
`function ReleasePalette;` |  | ReleasePalette - release the Handle used for the Palette.
`function CreateIntfImage;` |  | CreateIntfImage - creates an image on the Interface.
`property Canvas: TCanvas; [r]` |  | The Canvas where the raster image is rendered.
`function HandleAllocated;` |  | Indicates if a handle has been assigned for the shared image in the class.
`property BitmapHandle: HBITMAP; [rw]` |  | BitmapHandle - the Handle that has been allocated for the Bitmap.
`property Masked: Boolean; [rw]` |  | Masked - returns True if a Mask is being applied.
`property MaskHandle: HBITMAP; [rw]` |  | The handle allocated for the Bitmap Mask.
`property PixelFormat: TPixelFormat; [rw]` |  | Storage format for the Pixels in the Image.
`property RawImage: TRawImage; [r]` |  | Provides access to the raw image data for the image type.
`property ScanLine []: Pointer; [r] platform ;` |  | Provides indexed access to a scan line in the raw image data.
`property TransparentColor: TColor; [rw]` |  | Color used for transparent pixels in the image.
`property TransparentMode: TTransparentMode; [rw]` |  | Determines how transparent pixels are represented in the image.
`end;`

## Inheritance

`TRasterImage` |  | TRasterImage - base class for a number of graphic controls, including TCustomBitmap and TCustomIcon, which use a raster of dots to display graphic information.
`TGraphic` |  | Abstract base class used for images in supported image formats.
`TPersistent`
?
`TObject`

## Description

TRasterImage is a TGraphic descendant which implements the base class for images displayed as rasterized pixels on a canvas. It is used as the ancestor class for TCustomBitmap (TBitmap) and TCustomIcon (TIcon).

TRasterImage introduces the shared properties and methods common to the image formats. It is also provides a shared, reference-counted image that reduces resource requirements in graphical applications. Support is provided for bitmaps which use DIB (Device-Independent Bitmap) or DDB (Device-Dependent Bitmap) handles as well as common pixel storage formats used in the RawImage data. Handles are provided for the Bitmap, Mask, and Palette resources used in an image. TRasterImage also includes a Canvas used to render the pixels for the image.

Many of the methods in TRasterImage are defined as abstract virtual methods, and must be implemented in a descendent class to provide support for a specific image format.