|
Last change
on this file was 573, checked in by chronos, 17 months ago |
- Modified: Build with Lazarus 3.4.
- Modified: Removed U prefix from unit names.
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | unit MethodCanvasPixelsUpdateLock;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, DrawMethod, FastBitmap, Graphics;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | { TMethodCanvasPixelsUpdateLock }
|
|---|
| 10 |
|
|---|
| 11 | TMethodCanvasPixelsUpdateLock = class(TDrawMethodImage)
|
|---|
| 12 | constructor Create; override;
|
|---|
| 13 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
|---|
| 14 | end;
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | implementation
|
|---|
| 18 |
|
|---|
| 19 | { TMethodCanvasPixelsUpdateLock }
|
|---|
| 20 |
|
|---|
| 21 | constructor TMethodCanvasPixelsUpdateLock.Create;
|
|---|
| 22 | begin
|
|---|
| 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');
|
|---|
| 28 | end;
|
|---|
| 29 |
|
|---|
| 30 | procedure TMethodCanvasPixelsUpdateLock.DrawFrame(FastBitmap: TFastBitmap);
|
|---|
| 31 | var
|
|---|
| 32 | Y, X: Integer;
|
|---|
| 33 | begin
|
|---|
| 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;
|
|---|
| 43 | end;
|
|---|
| 44 |
|
|---|
| 45 | end.
|
|---|
| 46 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.