Line | |
---|
1 | unit UMethodCanvasPixelsUpdateLock;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, UDrawMethod, UFastBitmap, Graphics;
|
---|
9 |
|
---|
10 | type
|
---|
11 | { TMethodCanvasPixelsUpdateLock }
|
---|
12 |
|
---|
13 | TMethodCanvasPixelsUpdateLock = class(TDrawMethodImage)
|
---|
14 | constructor Create; override;
|
---|
15 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
---|
16 | end;
|
---|
17 |
|
---|
18 |
|
---|
19 | implementation
|
---|
20 |
|
---|
21 | { TMethodCanvasPixelsUpdateLock }
|
---|
22 |
|
---|
23 | constructor TMethodCanvasPixelsUpdateLock.Create;
|
---|
24 | begin
|
---|
25 | inherited;
|
---|
26 | Caption := 'TBitmap.Canvas.Pixels Update locking';
|
---|
27 | Description.Add('This method improves basic canvas pixel access by eliminating ' +
|
---|
28 | 'updating of visible area during complete operation. Image data is ' +
|
---|
29 | 'painted only one at the end of complete operation');
|
---|
30 | end;
|
---|
31 |
|
---|
32 | procedure TMethodCanvasPixelsUpdateLock.DrawFrame(FastBitmap: TFastBitmap);
|
---|
33 | var
|
---|
34 | Y, X: Integer;
|
---|
35 | begin
|
---|
36 | with FastBitmap do
|
---|
37 | try
|
---|
38 | Image.Picture.Bitmap.BeginUpdate(True);
|
---|
39 | for Y := 0 to Size.Y - 1 do
|
---|
40 | for X := 0 to Size.X - 1 do
|
---|
41 | Image.Picture.Bitmap.Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));
|
---|
42 | finally
|
---|
43 | Image.Picture.Bitmap.EndUpdate(False);
|
---|
44 | end;
|
---|
45 | end;
|
---|
46 |
|
---|
47 |
|
---|
48 | end.
|
---|
49 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.