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