source: GraphicTest/Methods/MethodCanvasPixelsUpdateLock.pas

Last change on this file was 573, checked in by chronos, 5 months ago
  • Modified: Build with Lazarus 3.4.
  • Modified: Removed U prefix from unit names.
File size: 1.1 KB
Line 
1unit MethodCanvasPixelsUpdateLock;
2
3interface
4
5uses
6 Classes, SysUtils, DrawMethod, FastBitmap, Graphics;
7
8type
9 { TMethodCanvasPixelsUpdateLock }
10
11 TMethodCanvasPixelsUpdateLock = class(TDrawMethodImage)
12 constructor Create; override;
13 procedure DrawFrame(FastBitmap: TFastBitmap); override;
14 end;
15
16
17implementation
18
19{ TMethodCanvasPixelsUpdateLock }
20
21constructor TMethodCanvasPixelsUpdateLock.Create;
22begin
23 inherited;
24 Caption := 'TBitmap.Canvas.Pixels Update locking';
25 Description.Add('This method improves basic canvas pixel access by eliminating ' +
26 'updating of visible area during complete operation. Image data is ' +
27 'painted only one at the end of complete operation');
28end;
29
30procedure TMethodCanvasPixelsUpdateLock.DrawFrame(FastBitmap: TFastBitmap);
31var
32 Y, X: Integer;
33begin
34 with FastBitmap do
35 try
36 Image.Picture.Bitmap.BeginUpdate(True);
37 for Y := 0 to Size.Y - 1 do
38 for X := 0 to Size.X - 1 do
39 Image.Picture.Bitmap.Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));
40 finally
41 Image.Picture.Bitmap.EndUpdate(False);
42 end;
43end;
44
45end.
46
Note: See TracBrowser for help on using the repository browser.