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

# TCustomImage

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

Implements the base class for TImage.

## Declaration

Source position: extctrls.pp line 529

`type TCustomImage = class(TGraphicControl)`
`protected`
`class procedure WSRegisterClass; override;` |  | Registers the class with the widgetset.
`procedure PictureChanged(); virtual;` |  | Performs actions needed when the Picture property has been changed.
`procedure CalculatePreferredSize(); override;` |  | Gets the preferred width and height used as the default size for the control.
`class function GetControlClassDefaultSize; override;` |  | Gets the default size for a new instance of the class type.
`procedure Paint; override;` |  | Draws the image to the control canvas.
`public`
`constructor Create(); override;` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destructor for the class instance.
`property Canvas: TCanvas; [r]` |  | Canvas used to draw the image.
`function DestRect; virtual;` |  | Gets the rectangle where the image is painted.
`procedure Invalidate; override;` |  | Causes the control to be repainted.
`property HasGraphic: Boolean; [r]`
`property AntialiasingMode: TAntialiasingMode; [rw]` |  | Indicates if anti-aliasing is used when rendering the image.
`property Align: TAlign;` |  | Specifies the placement of the control on its Parent control.
`property AutoSize: Boolean;` |  | Allows automatic adjustment of the size for the control, according to its content.
`property Center: Boolean; [rw]` |  | Indicates if the image should be centered.
`property KeepOriginXWhenClipped: Boolean; [rw]` |  | Preserves the Left coordinate when a clipped image is centered.
`property KeepOriginYWhenClipped: Boolean; [rw]` |  | Preserves the Top coordinate when a clipped image is centered.
`property Constraints: TSizeConstraints;` |  | Contains the minimum and maximum Width and Height for the control.
`property ImageIndex: Integer; [rw]`
`property ImageWidth: Integer; [rw]`
`property Images: TCustomImageList; [rw]`
`property Picture: TPicture; [rw]` |  | Contains the image displayed in the control.
`property Visible: Boolean;` |  | Allows the control, and all of its children, to be displayed or hidden.
`property OnClick: TNotifyEvent;` |  | Notification handler for mouse clicks.
`property OnMouseDown: TMouseEvent;` |  | Event handler signalled when a mouse down event is handled for the control.
`property OnMouseEnter: TNotifyEvent;` |  | Event handler signalled when the mouse pointer has entered the control.
`property OnMouseLeave: TNotifyEvent;` |  | Event handler signalled when the mouse pointer has left the control.
`property OnMouseMove: TMouseMoveEvent;` |  | Event handler signalled when the mouse pointer is moved in the control.
`property OnMouseUp: TMouseEvent;` |  | Event handler signalled when a mouse up event is handled for the control.
`property OnMouseWheel: TMouseWheelEvent;` |  | Event handler for mouse wheel turned.
`property OnMouseWheelDown: TMouseWheelUpDownEvent;` |  | Event handler signalled for a downward movement of the mouse wheel.
`property OnMouseWheelUp: TMouseWheelUpDownEvent;` |  | Event handler signalled for an upward movement of the mouse wheel.
`property Stretch: Boolean; [rw]` |  | Indicates if the image is resized to the client area for the control.
`property StretchOutEnabled: Boolean; [rw]` |  | Allows the image to be resized proportionally when the image drawing area is expanded.
`property StretchInEnabled: Boolean; [rw]` |  | Allows the image to be resized proportionally when the image drawing area is shrunk.
`property Transparent: Boolean; [rw]` |  | Indicates if the image has a clear, non-opaque background.
`property Proportional: Boolean; [rw]` |  | True if image is proportional.
`property OnPictureChanged: TNotifyEvent; [rw]` |  | Event handler signalled when Picture is changed.
`property OnPaintBackground: TImagePaintBackgroundEvent; [rw]` |  | Event handler signalled to draw the background for the image.
`end;`

## Inheritance

`TCustomImage` |  | Implements the base class for TImage.
`TGraphicControl` |  | TGraphicControl is the base class for all lightweight controls.
`TControl` |  | The base class for visible controls.
`TLCLComponent` |  | The base class for LCL components which have an associated widget.
`TComponent`
?
`TObject`

## Description

TCustomImage is a TGraphicControl descendent, and the base class for TImage. It is a lightweight and fast class used to display a graphic image using one of the image formats supported in the LCL. This includes:

- Bitmap
- Pixmap
- PNG
- JPEG
- GIF
- TIFF
- Icon

Use the Picture property to assign, load or save an image using one of the supported formats.

The Canvas property is used to render the graphic image in Picture, or to perform custom drawing operations on the image.

Use properties in the class instance to control how the image is rendered, including: AntialiasingMode, Center, Stretch, Transparent, and Proportional.

Do not create instances of TCustomImage; use the TImage descendant instead.

Use TImageList when a list of images with scaling capabilities is needed.

## See also

TImage |  | Implements a graphic image placed on a form, and usually loaded from a picture file.
TGraphicControl |  | TGraphicControl is the base class for all lightweight controls.
TPicture |  | Implements a container for TGraphic and descendent classes.
TGraphic |  | Abstract base class used for images in supported image formats.
TCanvas |  | Implements a drawing surface for a visual control or bitmap image.
TImageList |  | Implements a multi-resolution container for images used in an application.