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

# TCustomIcon

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

TCustomIcon - base class for TIcon.

## Declaration

Source position: graphics.pp line 1611

`type TCustomIcon = class(TRasterImage)`
`protected`
`FCurrent: Integer;` |  | Local member variable used to hold the current sequence number.
`FRequestedSize: TSize;` |  | Member used for the requested icon size.
`procedure MaskHandleNeeded; override;` |  | Ensures that a handle for the mask in the icon is valid.
`procedure PaletteNeeded; override;` |  | An empty implementation in TCustomIcon.
`function CanShareImage(); override;` |  | Indicates whether the image class type has a shared handle.
`procedure CheckRequestedSize;` |  | CheckRequestedSize - method to ensure correct size requested.
`function GetIndex();` |  | GetIndex - returns the Index value of the Icon with specified format and size (.icn files can contain several versions of image).
`function GetBitmapHandle; override;` |  | Gets the value for the BitmapHandle property.
`class function GetDefaultSize; virtual;` |  | GetDefaultSize - returns default size for Icon.
`function GetMaskHandle; override;` |  | Gets the value for the MaskHandle property.
`function GetPalette; override;` |  | Gets the value for the Palette property.
`function GetPixelFormat; override;` |  | Gets the value for the PixelFormat property.
`function GetRawImagePtr; override;` |  | Gets a pointer to the raw image data for the icon.
`function GetRawImageDescriptionPtr; override;` |  | Gets a pointer to the metadata for the raw image data.
`function GetTransparent; override;` |  | Gets the value for the Transparent property.
`class function GetSharedImageClass; override;` |  | Gets the class reference used to create new shared image instances in the class.
`class function GetStreamSignature; virtual;` |  | Gets the stream signature used for icon data.
`class function GetTypeID; virtual;` |  | Gets the icon type identifier used in the image list header.
`procedure HandleNeeded; override;` |  | Ensures that a handle for the image has been allocated.
`function InternalReleaseBitmapHandle; override;` |  | InternalReleaseBitmapHandle - releases Bitmap Handle and returns its value.
`function InternalReleaseMaskHandle; override;` |  | InternalReleaseMaskHandle - releases Mask Handle and returns its value.
`function InternalReleasePalette; override;` |  | InternalReleasePalette - releases Palette Handle and returns its value.
`class function IsStreamFormatSupported(); override;` |  | Indicates whether the specified stream contains image data with a format supported for use in derived TCustomIcon classes.
`procedure ReadData(); override;` |  | Reads data for the class instance from a stream.
`procedure ReadStream(); override;` |  | Reads the content for the icon from the specified stream.
`procedure SetMasked(); override;` |  | Sets the value for the Masked property.
`procedure SetPixelFormat(); override;` |  | Sets the value for the PixelFormat property.
`procedure SetTransparent(); override;` |  | Sets the value for the Transparent property.
`procedure UnshareImage(); override;` |  | Unshares the shared image when the content in the icon is changed.
`procedure UpdateCurrentView;` |  | UpdateCurrentView - updates the current appearance of the Icon.
`procedure SetHandle(); override;` |  | Unshares an existing shared image handle and set the new value.
`function UpdateHandle(); virtual;` |  | Updates the handle in the shared icon image top the specified value.
`function UpdateHandles(); override;` |  | Sets the Bitmap and Mask handles for the current image in the icon.
`procedure WriteStream(); override;` |  | Writes the content for the multi-image icon to the specified stream.
`public`
`constructor Create; override;` |  | Constructor for the class instance.
`procedure Add();` |  | Add - an Icon formatted as AFormat, with specified Height and Width.
`procedure Assign(); override;` |  | Copies values from the specified persistent object into the current class instance.
`procedure AssignImage(); virtual;` |  | Copies image data from the source image to the current icon image.
`procedure Clear; override;` |  | Removes the image content for the icon.
`procedure Delete();` |  | Deletes the image at the specified position in the list of images for the icon.
`procedure Remove();` |  | Removes an icon image with the specified attributes.
`procedure GetDescription();` |  | Gets metadata which describes the icon image at the specified position in the image list.
`procedure SetSize(); override;` |  | Sets the size (width, height) for the image in the Icon.
`class function GetFileExtensions; override;` |  | Gets a delimited list of file extensions supported for the image type.
`function LazarusResourceTypeValid(); override;` |  | Determines if the specified resource type is valid for the image format.
`procedure LoadFromResourceName(); override;` |  | Loads the icon with the specified resource name from the instance handle.
`procedure LoadFromResourceID(); override;` |  | Load icon data from a resource with the specified integer resource identifier.
`procedure LoadFromResourceHandle(); virtual;` |  | Loads icon data from the specified instance and resource handles.
`function BitmapHandleAllocated; override;` |  | Indicates if a handle for the icon image has been allocated.
`function MaskHandleAllocated; override;` |  | True if a handle has been allocated for the mask in the image.
`function PaletteAllocated; override;` |  | Determine if a handle has been allocated for the Palette in the icon.
`procedure SetHandles(); override;` |  | Not implemented in TCustomIcon.
`procedure Sort;` |  | Sorts the images for the icon.
`function GetBestIndexForSize();` |  | Gets the ordinal position for the image closest to the requested size.
`function ExportImage();` |  | Exports the image for the icon at the specified index to another TFPImageBitmap class instance.
`property Current: Integer; [rw]` |  | Ordinal position for the current image displayed for the icon.
`property Count: Integer; [r]` |  | Number of images in the image list for the shared icon.
`end;`

## Inheritance

`TCustomIcon` |  | TCustomIcon - base class for TIcon.
`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

TCustomIcon is a TRasterImage descendant which implements the base class for TIcon. TIcon supports image files using the .ICO file format. An .ICO file typically contains several images with different sizes and/or color depths.

TCustomIcon extends the ancestor class to include an internal list of images, and provides overridden methods which use the list of images in their implementations. This includes the ReadData method used during LCL component streaming. ReadStream is overridden to handle not only multiple images but PNG and DIB image formats used in some Icon files.

When loading an icon file, the largest/most colorful image is selected as the current image. Other sizes and/or color depths are accessed by setting the value in the Current property, or using Size when Current is not already set, or by setting Current to the value from the GetBestIndexForSize method.

Use the Count, Add, Delete, Remove, Clear, and AssignImage methods to maintain the images in the internal list.

Remark: | Please note that writing to an icon file is not currently implemented in TCustomIcon (or descendent classes).

## See also

TRasterImage |  | TRasterImage - base class for a number of graphic controls, including TCustomBitmap and TCustomIcon, which use a raster of dots to display graphic information.
TIcon |  | Implements an icon image type; small images typically associated with applications, controls, etc.
TSharedIcon |  | Implements a reference-counted shared Icon image type.