| Line | |
|---|
| 1 | unit UMethodCanvasPixels;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, UDrawMethod, UFastBitmap, Graphics;
|
|---|
| 9 |
|
|---|
| 10 | type
|
|---|
| 11 | { TMethodCanvasPixels }
|
|---|
| 12 |
|
|---|
| 13 | TMethodCanvasPixels = class(TDrawMethodCanvas)
|
|---|
| 14 | constructor Create; override;
|
|---|
| 15 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
|---|
| 16 | end;
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | implementation
|
|---|
| 20 |
|
|---|
| 21 | { TMethodCanvasPixels }
|
|---|
| 22 |
|
|---|
| 23 | constructor TMethodCanvasPixels.Create;
|
|---|
| 24 | begin
|
|---|
| 25 | inherited;
|
|---|
| 26 | Caption := 'TBitmap.Canvas.Pixels';
|
|---|
| 27 | Description.Add('This is simple naive approach to copy image by accessing Pixels property. ' +
|
|---|
| 28 | 'Method is slow because of much of overhead in access methods like multiple nested method calls, ' +
|
|---|
| 29 | 'pixel format conversion, update notification, etc.');
|
|---|
| 30 | end;
|
|---|
| 31 |
|
|---|
| 32 | procedure TMethodCanvasPixels.DrawFrame(FastBitmap: TFastBitmap);
|
|---|
| 33 | var
|
|---|
| 34 | Y, X: Integer;
|
|---|
| 35 | begin
|
|---|
| 36 | with FastBitmap do begin
|
|---|
| 37 | for Y := 0 to Size.Y - 1 do
|
|---|
| 38 | for X := 0 to Size.X - 1 do
|
|---|
| 39 | Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));
|
|---|
| 40 | end;
|
|---|
| 41 | end;
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | end.
|
|---|
| 45 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.