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