[Overview][Types][Classes][Index] | Reference for unit 'LazCanvas' (#lcl)

# TLazCanvas

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

Implements a canvas which masks differences between FCL and LCL canvas classes.

## Declaration

Source position: lazcanvas.pas line 82

`type TLazCanvas = class(TFPImageCanvas)`
`protected`
`procedure SetColor(); override;` |  | Sets the color for the pixel at the specified coordinates.
`function DoCreateDefaultFont; override;` |  | Creates the custom font used as the default for the canvas.
`procedure DoRectangle(); override;` |  | Adjusts the fcl-image coordinate system to be compatible with coordinates used in TCanvas.
`procedure DoRectangleFill(); override;` |  | Adjusts the FCL image rectangle to be LCL compatible and draws a filled rectangle on the canvas.
`procedure DoPolygonFill(); override;` |  | Implements a polygon fill algorithm not present in fcl-image prior to FPC version 3.2.3.
`procedure DoLine(); override;` |  | Draws a line using the specified coordinates and Pen for the canvas.
`procedure DoCopyRect(); override;` |  | Performs actions needed to copy a source rectangle from the specified canvas.
`procedure DoDraw(); override;` |  | Performs actions needed to draws the specified image at the given coordinates using AlphaBlending.
`public`
`HasNoImage: Boolean;` |  | Indicates if a valid image was provided in the constructor.
`NativeDC: PtrInt;` |  | Native device context for the canvas.
`ExtraFontData: TObject;` |  | Member with extra FreeType font data from the canvas or device context.
`ImageFormat: TLazCanvasImageFormat;` |  | Member with the TLazCanvasImageFormat instance used to speed up drawing.
`SelectedBitmap: TObject;` |  | Member with the GDI Handle for an image.
`constructor create();` |  | Constructor for the class instance.
`destructor destroy; override;` |  | Destructor for the class instance.
`procedure SetLazClipRegion();` |  | Sets the value in the ClipRegion property.
`function SaveState;` |  | Saves the current canvas state in the GraphicStateList member.
`procedure RestoreState();` |  | Restores the canvas to the state stored at the specified position.
`procedure ResetCanvasState;` |  | Sets the canvas to the default values/state used in the LCL TCanvas class.
`procedure AlphaBlend();` |  | Alpha blends the specified content from the source canvas onto the canvas instance.
`procedure AlphaBlendIgnoringDestPixels();` |  | Performs an AlphaBlend operation assuming a white background.
`procedure AlphaBlend_Image();` |  | AlphaBlends the specified image onto the canvas.
`procedure DoDrawImage();` |  | Calls DoDraw for the specified image and coordinates.
`procedure CanvasCopyRect();` |  | Copies the contents of a supported image format in ASource to the canvas.
`procedure FillColor();` |  | Fills the entire drawing area with the specified color.
`procedure Polygon(); overload;` |  | Overloaded method which adds support for the non-zero winding rule.
`procedure AssignPenData();` |  | Sets the Pen data for the canvas.
`procedure AssignBrushData();` |  | Sets the Brush data for the canvas.
`procedure AssignFontData();` |  | Sets the Font data for the canvas.
`property AssignedPen: TFPCustomPen; [rw]` |  | Pen assigned to the canvas.
`property AssignedBrush: TFPCustomBrush; [rw]` |  | Brush assigned to the canvas.
`property AssignedFont: TFPCustomFont; [rw]` |  | Font assigned to the canvas.
`property BaseWindowOrg: TPoint; [rw]` |  | Base window origin for the canvas.
`property WindowOrg: TPoint; [rw]` |  | Window origin for the canvas.
`end;`

## Inheritance

`TLazCanvas` |  | Implements a canvas which masks differences between FCL and LCL canvas classes.
`TFPImageCanvas`
?
`TObject`

## Description

TLazCanvas is an FCL TFPImageCanvas descendant. TLazCanvas extends the ancestor class to support stretching filters and features found in the TCanvas class from the LCL. TLazCanvas also fixes various small problems and incompatibilities between TFPImageCanvas versions, making the interface smoother and more consistent.

TLazCanvas is used in the implementation of custom-drawn widgetset classes, and provides a device context used to perform drawing operations for a control.

There are several useful examples using TLazCanvas on the Lazarus Wiki at:

Developing with Graphics

## See also

TCanvas |  | Implements a drawing surface for a visual control or bitmap image.