1 | unit MethodBitmapScanline;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | LCLIntf, LCLType, Classes, SysUtils, DrawMethod, FastBitmap, Controls, Graphics;
|
---|
7 |
|
---|
8 | type
|
---|
9 | { TMethodBitmapScanline }
|
---|
10 |
|
---|
11 | TMethodBitmapScanline = class(TDrawMethodCanvas)
|
---|
12 | Bitmap: TBitmap;
|
---|
13 | procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override;
|
---|
14 | constructor Create; override;
|
---|
15 | destructor Destroy; override;
|
---|
16 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
---|
17 | end;
|
---|
18 |
|
---|
19 |
|
---|
20 | implementation
|
---|
21 |
|
---|
22 | { TMethodBitmapScanline }
|
---|
23 |
|
---|
24 | procedure TMethodBitmapScanline.Init(Parent: TWinControl; Size: TPoint;
|
---|
25 | PixelFormat: TPixelFormat);
|
---|
26 | begin
|
---|
27 | inherited;
|
---|
28 | Bitmap.SetSize(Size.X, Size.Y);
|
---|
29 | end;
|
---|
30 |
|
---|
31 | constructor TMethodBitmapScanline.Create;
|
---|
32 | begin
|
---|
33 | inherited;
|
---|
34 | Caption := 'TBitmap Scanline PaintBox';
|
---|
35 | Bitmap := TBitmap.Create;
|
---|
36 | PaintObject := poCanvas;
|
---|
37 | Description.Add('This method uses TBitmap.ScanLine. ' +
|
---|
38 | 'PaintBox is used to display image data.');
|
---|
39 | end;
|
---|
40 |
|
---|
41 | destructor TMethodBitmapScanline.Destroy;
|
---|
42 | begin
|
---|
43 | FreeAndNil(Bitmap);
|
---|
44 | inherited;
|
---|
45 | end;
|
---|
46 |
|
---|
47 | procedure TMethodBitmapScanline.DrawFrame(FastBitmap: TFastBitmap);
|
---|
48 | var
|
---|
49 | X, Y: Integer;
|
---|
50 | P: PCardinal;
|
---|
51 | begin
|
---|
52 | Bitmap.BeginUpdate;
|
---|
53 | with FastBitmap do
|
---|
54 | for Y := 0 to Size.Y - 1 do begin
|
---|
55 | P := Bitmap.ScanLine[Y];
|
---|
56 | for X := 0 to Size.X - 1 do begin
|
---|
57 | P^ := NoSwapBRComponent(Pixels[X, Y]);
|
---|
58 | Inc(P);
|
---|
59 | end;
|
---|
60 | end;
|
---|
61 | Bitmap.EndUpdate;
|
---|
62 | BitBlt(Canvas.Handle, 0, 0, FastBitmap.Size.X, FastBitmap.Size.Y, Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
|
---|
63 | end;
|
---|
64 |
|
---|
65 | end.
|
---|
66 |
|
---|