| ImageEn, unit imageenview |
|
TImageEnView.BackBufferImage
Declaration
property BackBufferImage: TIEBitmap;
Description
Provides access to the back buffer where ImageEn will draw the image (and layers) prior to the paint event.
Use the
OnDrawBackBuffer event to paint to the Back Buffer canvas.
The BackBuffer is the same size as the TImageEnView control, where 0,0 is the top-left drawn pixel. Do
not attempt to resize the Back Buffer.
BackBuffer is updated whenever
Update is called.
Note: BackBuffer is only updated when the control not visible. To force an update of the BackBuffer, add iedoPaintWhenOffScreen to
DisplayOptions
Demo
| Demos\Other\CellsAndGrid\CellsAndGrid.dpr |
Examples
Procedure Form1OnDrawBackBuffer(Sender: TObject);
begin
// Draw a red line on the back buffer
With ImageEnView1.BackBufferImage.IECanvas 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 TForm1.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.BackBufferImage.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;
// Use a trackbar to darken the image (call ImageEnView1.Update from the Trackbar's OnChange event)
procedure DarkenBitmap(Bitmap: TBitmap; Brightness: Integer);
type
TRGBTripleArray = ARRAY[Word] of TRGBTriple;
pRGBTripleArray = ^TRGBTripleArray;
var
x, y: Integer;
Row: PRGBTripleArray;
R, G, B: Byte;
begin
if ( Bitmap.PixelFormat <> pf24bit ) or ( Brightness < 0 ) or ( Brightness > 100 ) then
raise Exception.Create( 'Cannot darken' );
for y := 0 to Bitmap.Height - 1 do
begin
Row := Bitmap.Scanline[y];
for x := 0 to Bitmap.Width - 1 do
begin
// Get RGB components
R := Row[x].rgbtRed;
G := Row[x].rgbtGreen;
B := Row[x].rgbtBlue;
// Apply brightness scaling
Row[x].rgbtRed := Round( R * Brightness / 100.0 );
Row[x].rgbtGreen := Round( G * Brightness / 100.0 );
Row[x].rgbtBlue := Round( B * Brightness / 100.0 );
end;
end;
end;
procedure TForm1.ImageEnView1DrawBackBuffer(Sender: TObject);
begin
DarkenBitmap( ImageEnView1.BackBufferImage.VclBitmap, TrackBar1.Position ); // 0=Black, 100=Full Brightness
end;
See Also
◼OnDrawBackBuffer
Compatibility Information
Prior to v15.1.0, the back buffer was exposed a TBitmap with the
BackBuffer property (equivalent to BackBufferImage.VclBitmap). Code that was:
ImageEnView1.BackBuffer.Canvas.TextOut(100, 100, 'Test');
Should change to:
ImageEnView1.BackBufferImage.VclBitmap.Canvas.TextOut(100, 100, 'Test');