Using Canvas Class
Using Canvas Class
Class [TImagingCanvas] in [ImagingCanvases.pas]
unit allows library user to draw onto image and apply various effects.
Base canvas class works for all image data formats with direct pixel access
(so not for compressed formats).
Because of this some operations are slower (sometimes a lot)
than implementation optimized for just one data format
(as it is done for example in Graphics32 library).
Descendants optimized for specific data formats can be created.
Currently there is only most basic [TFastARGB32Canvas] class
for ifA8R8G8B8 images.
Canvas can be created for both low and high level images.
Image data is only referenced by canvas.
If you change image data size (like format conversion or resizing)
you must update canvas by calling UpdateCanvasState
method so that canvas can update its helper structures depending
on size of the data (like scanline pointers).
You only need to update the canvas when size of image data
changes, not after setting pixels or drawing outside of the canvas
(like using [CopyRect] function).
Currently Canvas class has these features:
Set pen and fill color in 32bit and FP format. Set
pen width and pen/fill mode (supported only in few functions).
Set and get pixel colors.
Clipping against custom rectangle.
Draw lines, framed rectangles, and ellipses.
Fill rectangles with solid color or with blending.
Draw part of canvas onto another canvas.
Stretch part of canvas onto another canvas with filtering (bilinear/bicubic/nearest).
Drawing (Draw/StretchDraw/FillRect) with blending.
Several source and destination blending factors are supported
(so you can get alpha blending, adding, modulate, ...).
Linear filters (convolution) with custom kernels and some predefined.
Nonlinear filters with custom functions and some predefined (min, max, median).
Point filters with custom functions and some predefined (contrast, gamma, thresholding, brightness,
premultiply alpha, ...).
You can find some canvas usage code in Tips article linked bellow
and in the demos. There is still a lot of functions that can be added to
canvas and hopefully they will be.
More Canvas Info
Canvas Class Tips
VCL Image Browser Demo
LCL Imager Demo