Classes and functions for extending TFPImageCanvas.

lazcanvas.pas contains classes and functions for extending TFPImageCanvas to support more stretching filters, and to support all features from the LCL TCanvas. TLazCanvas also fixes various small problems and incompatibilities between TFPImageCanvas versions, making the interface smoother and more consistent.

Do not use anything from the LCL here, as this unit should be kept strictly independent. LCLProc.pas is allowed for DebugLn, but only during debugging or profiling.

Author: Felipe Monteiro de Carvalho

Identifies image formats supported in TLazCanvas.

Used in the implementation of the CanvasCopyRect method in TLazCanvas, and in custom-drawn LCL controls to speed up image drawing in the LCL interface.

Images use a format other than those in this enumeration. Images use 16-bit RGB colors. Images use 24-bit RGB colors. Images use 24-bit RGB colors with inverse values. Images use 24-bit BGR colors. Images use 32-bit BGR colors with an Alpha channel. Images use 32-bit RGB colors with an Alpha channel. Images use 32-bit RGB colors with an Alpha channel in the low-order octet. Implements a very sharp and square interpolation.

TFPSharpInterpolation implements a very sharp and square interpolation for stretching, similar to StretchBlt from the Windows API.

Paints an image on the Canvas using the specified coordinates and dimensions. Horizontal coordinate. Vertical coordinate. Width for the output. Height for the output. Contains properties reflecting the state for a Lazarus canvas.

TLazCanvasState is a class with public members that reflect the state for a TLazCanvas instance. A destructor is provided to ensure that resources allocated to members variables are freed before the class instance is destroyed.

Instances of TLazCanvasState are created, stored, and retrieved using an internal list in TLazCanvas in its SaveState and RestoreState methods.

Brush for the canvas. Pen for the canvas. Font for the canvas. Base window origin for the canvas.

The values in WindowOrg are relative to the coordinates in BaseWindowOrg. BaseWindowOrg coordinates are relative to the canvas for the containing Form. It is useful when implementing the non-native windowed controls.

Window origin for the canvas.

Contains the absolute coordinates for the canvas with BaseWindowOrg summed up.

Indicates if Clipping is enabled for the canvas. Defines the clipping region for the canvas. Destructor for the class instance.

Destroy is the overridden destructor for the class instance. Destroy ensures that resources allocated for the Brush and Pen properties are freed before the class instance is destroyed. Destroy calls the inherited destructor prior to exiting from the method.

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

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.

TCanvas
Stores saved canvas state information.

Used to store and restore canvas states in the SaveState and RestoreState methods. Contains TLazCanvasState class instances.

Gets the value for the AssignedBrush property. Value for the property. Gets the value for the AssignedPen property. Value for the property. Gets the value for the AssignedFont property. Value for the property. Gets the value for the WindowOrg property. Value for the property. Sets the value for the WindowOrg property. New value for the property. Sets the color for the pixel at the specified coordinates. Horizontal pixel coordinate. Vertical pixel coordinate. Color for the pixel. Creates the custom font used as the default for the canvas.

DoCreateDefaultFont is an overridden TFPCustomFont function used to provide the default font for the canvas class instance. DoCreateDefaultFont implements the abstract virtual method defined in an ancestor class, and emulates the method defined in TCanvas.

DoCreateDefaultFont sets the Size property in the font to zero (0); this causes the default font size for the platform or widget set to be used. The FPColor property in the font is set to colBlack.

TFPCustomFont instance created and initialized in the method. Adjusts the fcl-image coordinate system to be compatible with coordinates used in TCanvas.

Adjusts the values in Bounds to use the coordinate system in TCanvas, and draws borders using the style and/or pattern in the Pen for the canvas.

DoRectangleFill is used to optimize and fill a rectangle area.

TRect with the bounds for the rectangular area. Adjusts the FCL image rectangle to be LCL compatible.

Adjusts the fcl-image coordinate system to be compatible with coordinates used in TCanvas.

Rectangle bounds adjusted in the method. Implements a polygon fill algorithm not present in fcl-image.

Implements a polygon fill algorithm not present in fcl-image. The algorithm is explained here.

Array with the TPoint instances for the polygon corners. Draws a line using the specified coordinates and Pen for the canvas. Initial horizontal coordinate for the line. Initial vertical coordinate for the line. Terminal horizontal coordinate for the line. Terminal vertical coordinate for the line. Copies a source rectangle to the specified canvas. Draws the specified image at the given coordinates using AlphaBlending. Indicates if a valid image was provided in the constructor.

HasNoImage is a Boolean member used to indicate if a valid TFPCustomImage was provided as an argument to the Create constructor. Used in the implementation of the UpdateControlLazImageAndCanvas routine for non-native custom drawn window controls.

Native device context for the canvas.

NativeDC is a PtrInt member which contains the device context used to render a custom-drawn LCL control.

Member with extra FreeType font data from the canvas or device context. Used in custom-drawn LCL controls. Member with the TLazCanvasImageFormat instance used to speed up drawing. Member with the GDI Handle for an image. Used in custom-drawn LCL controls. Constructor for the class instance.

Create is the constructor for the class instance. Create calls the inherited constructor using AnImage as an argument.

Create allocates resources for the GraphicStateList property. Create sets the value for the HasNoImage member to True when AnImage has not been assigned (contains Nil).

Screen image for the control rendered on the canvas. Destructor for the class instance.

Destroy is the overridden destructor for the class instance. Destroy ensures that resources allocated for GraphicStateList, AssignedBrush, and AssignedPen are freed. Destroy calls the inherited destructor prior to exiting from the method.

Sets the value in the ClipRegion property. Region stored in the property. Saves the current canvas state in the GraphicStateList member.

SaveState is an Integer function used to save the current canvas state in the GraphicStateList member. SaveState creates an instance of TLazCanvasState with copies of the current values for Brush, Pen, and Font. Values from BaseWindowOrg, WindowOrg, and Clipping are also assigned to the class instance.

The return value contains the ordinal position in GraphicStateList where the canvas state was added in the method.

Use RestoreState to restore the canvas to the state stored at a specified position in the list.

Ordinal position in GraphicStateList where the saved canvas state was stored. Restores the canvas to the state stored at the specified position. Ordinal position in GraphicStateList restored in the method. Sets the canvas to the default values/state used in the LCL TCanvas class. Performs an AlphaBlend operation using the specified source canvas. Performs an AlphaBlend operation assuming a white background.

This is a safer version for use where the destination pixels may not be consistent or valid. It will draw as if the target area contained opaque white pixels.

AlphaBlends the specified image onto the canvas. Calls DoDraw for the specified image and coordinates. Copies the contents of a supported image format in ASource to the canvas. Fills the entire drawing area with the specified color.

Fills the entire drawing area with the specified color. AIgnoreClippingAndWindowOrg speeds up canvas drawing operations, but it is dangerous; don't use it unless you know what you are doing.

Color applied to the canvas area. Sets the Pen data for the canvas.

Utilized by LCLIntf.SelectObject and by the RestoreState method. This is needed because calling Assign for the Pen, Brush, or Font properties raises exceptions.

Sets the Brush data for the canvas.

Utilized by LCLIntf.SelectObject and by the RestoreState method. This is needed because calling Assign for the Pen, Brush, or Font properties raises exceptions.

Srts the Font data for the canvas.

Utilized by LCLIntf.SelectObject and by the RestoreState method. This is needed because calling Assign for the Pen, Brush, or Font properties raises exceptions.

Pen assigned to the canvas.

These properties are utilized to implement LCLIntf.SelectObject to keep track of which pen/brush/font handle was assigned to this canvas. They are not utilized by TLazCanvas itself.

Brush assigned to the canvas.

These properties are used to implement LCLIntf.SelectObject to keep track of which pen/brush/font handle was assigned to this canvas. They are not utilized by TLazCanvas itself.

Font assigned to the canvas.

These properties are used to implement LCLIntf.SelectObject to keep track of which pen/brush/font handle was assigned to this canvas. They are not utilized by TLazCanvas itself.

Base window origin for the canvas.

The values in WindowOrg are relative to the coordinates in BaseWindowOrg. BaseWindowOrg coordinates are relative to the canvas for the containing Form. It is useful when implementing the non-native windowed controls.

Clipping region for the canvas. Window origin for the canvas.

Contains the absolute coordinates for the canvas with BaseWindowOrg summed up.