Sign in Join
FPDoc Onlineexperiment

TCustomImageList.AddMultipleResolutions function

Member of TCustomImageListpublicIn unit ImgList

Adds images with varying sizes to the corresponding image resolution.

Declaration

pascal
function AddMultipleResolutions
 (Images: Array of TCustomBitmap = class(TRasterImage)
private
 FPixelFormat: TPixelFormat;
 FPixelFormatNeedsUpdate: Boolean;
 FMaskHandle: HBITMAP;
 function GetHandleType: TBitmapHandleType;
 function GetMonochrome: Boolean;
 procedure SetBitmapHandle(const AValue: HBITMAP);
 procedure SetHandleType(AValue: TBitmapHandleType);
 procedure SetMonochrome(AValue: Boolean);
 procedure UpdatePixelFormat;
protected
 procedure MaskHandleNeeded; override;
 procedure PaletteNeeded; override;
 function CanShareImage(AClass: TSharedRasterImageClass): Boolean
 ; override;
 procedure Changed(Sender: TObject); override;
 function CreateDefaultBitmapHandle(const ADesc: TRawImageDescription)
: HBITMAP; override;
 procedure FreeMaskHandle;
 function GetBitmapHandle: HBITMAP; override;
 function GetMaskHandle: HBITMAP; override;
 function GetPalette: HPALETTE; override;
 function GetPixelFormat: TPixelFormat; override;
 function GetRawImagePtr: PRawImage; override;
 function GetRawImageDescriptionPtr: PRawImageDescription; override;
 class function GetSharedImageClass: TSharedRasterImageClass; override;
 procedure HandleNeeded; override;
 function InternalReleaseBitmapHandle: HBITMAP; override;
 function InternalReleaseMaskHandle: HBITMAP; override;
 function InternalReleasePalette: HPALETTE; override;
 procedure RawimageNeeded(ADescOnly: Boolean);
 procedure SetHandle(AValue: TLCLHandle); override;
 procedure SetPixelFormat(AValue: TPixelFormat); override;
 procedure UnshareImage(CopyContent: Boolean); override;
 function UpdateHandles(ABitmap: HBITMAP; AMask: HBITMAP): Boolean
 ; override;
public
 constructor Create; override;
 destructor Destroy; override;
 procedure Assign(Source: TPersistent); override;
 procedure Clear; override;
 procedure FreeImage; override;
 function LazarusResourceTypeValid(const ResourceType: string): Boolean
 ; override;
 function BitmapHandleAllocated: Boolean; override;
 function MaskHandleAllocated: Boolean; override;
 function PaletteAllocated: Boolean; override;
 function ReleaseHandle: HBITMAP;
 procedure SetHandles(ABitmap: HBITMAP; AMask: HBITMAP); override;
 procedure SetSize(AWidth: Integer; AHeight: Integer); override;
 property Handle: HBITMAP;
 property HandleType: TBitmapHandleType;
 property Monochrome: Boolean;
end
)
: Integer
function AddMultipleResolutions
 (Images: Array of TRasterImage = class(TGraphic)
private
 FCanvas: TCanvas;
 FTransparentColor: TColor;
 FTransparentMode: TTransparentMode;
 FUpdateCount: Integer;
 FUpdateCanvasOnly: Boolean;
 FMasked: Boolean;
 FTransparentPending: Boolean;
 FTransparentDelayed: Boolean;
 procedure CanvasChanging(Sender: TObject);
 procedure CreateCanvas;
 procedure CreateMask(AColor: TColor=clDefault);
 procedure FreeCanvasContext;
 function GetCanvas: TCanvas;
 function GetRawImage: TRawImage;
 function GetScanline(ARow: Integer): Pointer;
 function GetTransparentColor: TColor;
 procedure SetTransparentColor(AValue: TColor);
protected
 FSharedImage: TSharedRasterImage;
 function CanShareImage(AClass: TSharedRasterImageClass): Boolean
 ; virtual;
 procedure Changed(Sender: TObject); override;
 function CreateDefaultBitmapHandle(const ADesc: TRawImageDescription)
: HBITMAP; virtual;
 procedure Draw(DestCanvas: TCanvas; const DestRect: TRect); override;
 function GetEmpty: Boolean; override;
 function GetHandle: TLCLHandle;
 function GetBitmapHandle: HBITMAP; virtual; abstract;
 function GetMasked: Boolean; virtual;
 function GetMaskHandle: HBITMAP; virtual; abstract;
 function GetMimeType: string; override;
 function GetPixelFormat: TPixelFormat; virtual; abstract;
 function GetRawImagePtr: PRawImage; virtual; abstract;
 function GetRawImageDescriptionPtr: PRawImageDescription; virtual
 ; abstract;
 function GetTransparent: Boolean; override;
 class function GetSharedImageClass: TSharedRasterImageClass; virtual;
 function GetHeight: Integer; override;
 function GetWidth: Integer; override;
 procedure BitmapHandleNeeded; virtual;
 procedure HandleNeeded; virtual; abstract;
 procedure MaskHandleNeeded; virtual; abstract;
 procedure PaletteNeeded; virtual; abstract;
 function InternalReleaseBitmapHandle: HBITMAP; virtual; abstract;
 function InternalReleaseMaskHandle: HBITMAP; virtual; abstract;
 function InternalReleasePalette: HPALETTE; virtual; abstract;
 procedure SetBitmapHandle(AValue: HBITMAP);
 procedure SetMasked(AValue: Boolean); virtual;
 procedure SetMaskHandle(AValue: HBITMAP);
 procedure SetTransparent(AValue: Boolean); override;
 procedure UnshareImage(CopyContent: Boolean); virtual; abstract;
 function UpdateHandles(ABitmap: HBITMAP; AMask: HBITMAP): Boolean
 ; virtual; abstract;
 procedure SaveStreamNeeded;
 procedure FreeSaveStream;
 procedure ReadData(Stream: TStream); override;
 procedure ReadStream(AStream: TMemoryStream; ASize: LongInt); virtual
 ; abstract;
 procedure SetSize(AWidth: Integer; AHeight: Integer); virtual
 ; abstract;
 procedure SetHandle(AValue: TLCLHandle); virtual;
 procedure SetHeight(AHeight: Integer); override;
 procedure SetWidth(AWidth: Integer); override;
 procedure SetTransparentMode(AValue: TTransparentMode);
 procedure SetPixelFormat(AValue: TPixelFormat); virtual; abstract;
 procedure WriteData(Stream: TStream); override;
 procedure WriteStream(AStream: TMemoryStream); virtual; abstract;
 function RequestTransparentColor: TColor;
 procedure ApplyTransparent;
public
 constructor Create; override;
 destructor Destroy; override;
 procedure Assign(Source: TPersistent); override;
 procedure Clear; override;
 procedure BeginUpdate(ACanvasOnly: Boolean=False);
 procedure EndUpdate(AStreamIsValid: Boolean=False);
 procedure FreeImage; virtual;
 function BitmapHandleAllocated: Boolean; virtual; abstract;
 function MaskHandleAllocated: Boolean; virtual; abstract;
 function PaletteAllocated: Boolean; virtual; abstract;
 procedure LoadFromBitmapHandles(ABitmap: HBitmap; AMask: HBitmap; 
 ARect: PRect=Nil);
 procedure LoadFromDevice(DC: HDC); virtual;
 LoadFromStream;
 procedure LoadFromMimeStream(AStream: TStream; const AMimeType: string)
 ; override;
 procedure LoadFromRawImage(const AIMage: TRawImage; ADataOwner: Boolean);
 procedure LoadFromIntfImage(IntfImage: TLazIntfImage);
 procedure SaveToStream(AStream: TStream); override;
 procedure GetSupportedSourceMimeTypes(List: TStrings); override;
 procedure GetSize(out AWidth: Integer; out AHeight: Integer);
 procedure Mask(ATransparentColor: TColor);
 procedure SetHandles(ABitmap: HBITMAP; AMask: HBITMAP); virtual
 ; abstract;
 function ReleaseBitmapHandle: HBITMAP;
 function ReleaseMaskHandle: HBITMAP;
 function ReleasePalette: HPALETTE;
 function CreateIntfImage: TLazIntfImage;
 property Canvas: TCanvas;
 function HandleAllocated: Boolean;
 property BitmapHandle: HBITMAP;
 property Masked: Boolean;
 property MaskHandle: HBITMAP;
 property PixelFormat: TPixelFormat;
 property RawImage: TRawImage;
 property ScanLine[Row: Integer]: Pointer; platform;;
 property TransparentColor: TColor;
 property TransparentMode: TTransparentMode;
end
)
: Integer

Arguments

Images

Array of images stored in the method.

Function result

Ordinal position where images were stored in the various resolutions.

Description

AddMultipleResolutions is an Integer function used to add images of varying sizes to the corresponding resolution in the image list.

AImages is an array of TCustomBitmap type with the images added in the method. Each image has a unique width that determines the image resolution where the image is stored. AImages must be sorted in ascending image width order before it is passed as an argument to the method.

The return value contains the ordinal position where the images were stored in the image resolutions. It should contain the value corresponding to Count-1 when the method is completed.

AddMultipleResolutions calls the CreateDefaultResolution method to ensure that the default image resolution has been created before adding images to the list.

The Resolutions enumerator is used to visit each of the TCustomImageListResolution instances used in the image list. Each image in AImages is compared to the image resolutions to determine if the width is already in use. If no exact match is found, the next larger image resolution is used. If no resolution is larger than the image width, the largest image resolution is used.

The ScaleImage method is called to resize the image in AImages to the height and width required for the target image resolution. The image is appended using the InternalInsert method in the image resolution to store the scaled raw image data.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.