Updated: 29.11.2016
Rus

TsAlphaImageList

This component is an analogue of standard TImageList component, but there are some significant differences:

  • Changing of Height and Width properties without loss of icons.
  • It's possible to use this component as a storage of images with different sizes.
  • Allowed formats of icons : Ico, Png and Bmp 32bpp.
  • Images are embedded in executable file in the original format (with compression).
  • Support of the NumGlyphs property of buttons.

Component methods

procedure AcBeginUpdate;
Suppresses an output of images, used when component is in changing usually.

procedure AcEndUpdate(DoChange : boolean = True);
Allows an output of images, used for unlock of component after the AcBeginUpdate procedure calling. If the DoChange parameter is True, then repainting command is sent to all components, linked with this ImageList.

function GetBitmap32(Index: Integer; Image: TBitmap): Boolean;
Returns to the Image an Icon by Index with converting to Bitmap 32bpp format. If function is executed with success then result is True.

function CreateBitmap32(Index: Integer; aWidth, aHeight : integer): TBitmap;
Creates a Bitmap 32bpp with specified size, based on the icon from ImageList. If function is executed with success then result is not Nil.

procedure MoveItem(CurIndex, NewIndex : integer);
Changes a position of the icon in the list.

TsVirtualImageList

Component allows to receive an images with specified size with using of the TsAlphaImageList component as a source of images. TsVirtualImageList component does not stores images, but takes them from component defined in the AlphaImageList property.

Sample of using of the TsVirtualImageList with TsAlphaImageList may be downloaded there (3.7 Mb).

Component methods

procedure AcBeginUpdate;
Suppresses an output of images, used when component is in changing usually.

procedure AcEndUpdate(DoChange : boolean = True);
Allows an output of images, used for unlock of component after the AcBeginUpdate procedure calling. If the DoChange parameter is True, then repainting command is sent to all components, linked with this ImageList.

function GetBitmap32(Index: Integer; Image: TBitmap): Boolean;
Returns to the Image an Icon by Index with converting to Bitmap 32bpp format. If function is executed with success then result is True.

function CreateBitmap32(Index: Integer; aWidth, aHeight : integer): TBitmap;
Creates a Bitmap 32bpp with specified size, based on the icon from ImageList. If function is executed with success then result is not Nil.

Procedures and functions of the unit

function DrawAlphaImgList(const ImgList : TCustomImageList; const DestBmp : TBitmap; const Left : integer; const Top : integer; const ImageIndex : integer; const Blend : integer; const GrayedColor : TColor; State : integer; const NumGlyphs : integer; const Reflected : boolean) : TSize;

Draws an image from ImgList, which defined by ImageIndex, to the DestBmp in the Bitmap 32bpp. Output of images may be produced with several effects, such as semitransparency, reflection and others. Result of function is a size of the image.

  • Left and Top parameters specifies coords of the top left corner, where should be drawn the image.
  • State specifies a number of state for which the icon will be drawn. Such effects as semitransparency and color tone may be produced only if State is 0.
  • NumGlyphs specifies a count of states in the one image. This property works same as NumGlyphs property in the standard TBitBtn component.
  • Blend defines a level of the image transparency (0..100). If this property is 0 or if State <> 0, them image will be drawn as is, without a transparency. The sample shows images with Blend = 0 and 50.
  • GrayedColor specifies a color tone for an icon. If GrayedColor is clNone or State <> 0, then icons will be drawn as is, without changes. The lighter color makes more clear icon. Below are shown samples of icons with clNone and $BEA76D colors.
  • Reflected enables a reflection for the icon. On a sample are shown icons with enabled and with disabled Reflected parameter.


procedure DrawAlphaImgListDC(const ImgList : TCustomImageList; const DC : hdc; const Left : integer; const Top : integer; const ImageIndex : integer; const Blend : integer; const GrayedColor : TColor; const State : integer; const NumGlyphs : integer; const Reflected : boolean);

A full analog of the previous function. Difference is in destination only. Output produced to the DeviceContext handle in this procedure (DC: hdc).


function AddImageFromRes(aInstance: LongWord; ImageList : TsAlphaimageList; const ResName: String; ImageFormat : TsImageFormat): Boolean;

Loads the Png icon from resource to the ImageList. Resource image is defined by ResName: String and should be compiled as RcData.