Declaration
property OnDrawBackBuffer: TNotifyEvent;
Description
OnDrawBackBuffer provides access to the back buffer where ImageEn draws the image (and layers) just before the paint event.
Drawing to the back buffer will appear over the image and layers, but beneath screen controls such as selection rectangles.
You can draw on the
BackBuffer by handling the OnDrawBackBuffer event to paint onto the Backbuffer canvas.
BackBuffer is updated whenever
Update is called (not when only invalidating the control).
ImageEnView Paint Events
The main paint events of TImageEnView are
OnDrawBackBuffer which occurs when the back buffer is painted and
OnDrawCanvas which occurs every time the canvas is painted. Generally
OnDrawBackBuffer is used for better performance, because the back buffer painting only occurs after the content is
updated. If you need constant custom drawing (e.g. to draw a marker at the current cursor position) then use
OnDrawCanvas.
In layer applications,
OnBeforeDrawLayer and
OnDrawLayer will occur while painting each individual layer. Use these methods if you need easy custom drawing upon each individual layer (e.g. a layer title). Generally
OnBeforeDrawLayer is best, unless you need to paint to the whole image (i.e. outside the area of the layer).
Other drawing events:
◼OnDrawBackground occurs when the background (area behind the image is painted) is painted to allow custom background styling
◼OnDrawLayerBox occurs when the
box around a
layer is painted to allow custom styling of the box
◼OnDrawLayerGrip occurs when the
grips of the selected
layer are drawn to allow custom grip styling
◼OnTransitionPaint occurs while
transitioning from one image to the next
◼OnPaint notifies whenever there is a paint event. It is not used for custom drawing
◼OnDrawPolygon notifies whenever a point of a polygonal selection is drawn
| Demos\Other\CellsAndGrid\CellsAndGrid.dpr |
Procedure Form1OnDrawBackBuffer(Sender: TObject);
Begin
// Draw a red line on the back buffer
With ImageEnView1.BackBuffer.Canvas do
begin
Pen.Color := clRed;
MoveTo( 0, 0 );
LineTo( 100, 100 );
End;
End;
// Draw a box around all selected layers
// Note: To prevent the default layer selection box being drawn, create an empty OnDrawLayerBox event
procedure Tfmain.ImageEnView1DrawBackBuffer(Sender: TObject);
var
cab: TRect;
i, minX, minY, maxX, maxY : Integer;
begin
minX := MAXINT;
minY := MAXINT;
maxX := 0;
maxY := 0;
for I := 0 to ImageEnView1.LayersCount - 1 do
if ImageEnView1.Layers[ i ].Selected then
begin
cab := ImageEnView1.Layers[i].ClientAreaBox;
minX := imin( minX, cab.Left );
minY := imin( minY, cab.Top );
maxX := imax( maxX, cab.Right );
maxY := imax( maxY, cab.Bottom );
end;
// Draw green rect
if minX < MAXINT then
with ImageEnView1.BackBuffer.Canvas do
begin
Pen.Style := psSolid;
Pen.Width := 2;
Pen.mode := pmCopy;
Pen.Color := clGreen;
Brush.Style := bsClear;
Rectangle( minX - 1, minY - 1, maxX + 1, maxY + 1 );
end;
end;