1 | unit MethodBGRABitmap;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, DrawMethod, FastBitmap, BGRABitmap, BGRABitmapTypes,
|
---|
7 | Controls, Graphics;
|
---|
8 |
|
---|
9 | type
|
---|
10 | { TMethodBGRABitmap }
|
---|
11 |
|
---|
12 | TMethodBGRABitmap = class(TDrawMethodCanvas)
|
---|
13 | BGRABitmap: TBGRABitmap;
|
---|
14 | procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override;
|
---|
15 | constructor Create; override;
|
---|
16 | destructor Destroy; override;
|
---|
17 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
---|
18 | end;
|
---|
19 |
|
---|
20 |
|
---|
21 | implementation
|
---|
22 |
|
---|
23 | { TMethodBGRABitmap }
|
---|
24 |
|
---|
25 | procedure TMethodBGRABitmap.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
|
---|
26 | begin
|
---|
27 | inherited;
|
---|
28 | BGRABitmap.SetSize(Size.X, Size.Y);
|
---|
29 | end;
|
---|
30 |
|
---|
31 | constructor TMethodBGRABitmap.Create;
|
---|
32 | begin
|
---|
33 | inherited;
|
---|
34 | Caption := 'TBGRABitmap';
|
---|
35 | BGRABitmap := TBGRABitmap.Create(0, 0);
|
---|
36 | PaintObject := poPaintBox;
|
---|
37 | Description.Add('This method uses graphic library BGRABitmap. ' +
|
---|
38 | 'PaintBox is used to display image data.');
|
---|
39 | end;
|
---|
40 |
|
---|
41 | destructor TMethodBGRABitmap.Destroy;
|
---|
42 | begin
|
---|
43 | BGRABitmap.Free;
|
---|
44 | inherited;
|
---|
45 | end;
|
---|
46 |
|
---|
47 | procedure TMethodBGRABitmap.DrawFrame(FastBitmap: TFastBitmap);
|
---|
48 | var
|
---|
49 | X, Y: Integer;
|
---|
50 | P: PCardinal;
|
---|
51 | begin
|
---|
52 | with FastBitmap do
|
---|
53 | for Y := 0 to Size.Y - 1 do begin
|
---|
54 | P := PCardinal(BGRABitmap.ScanLine[Y]);
|
---|
55 | for X := 0 to Size.X - 1 do begin
|
---|
56 | P^ := SwapBRComponent(Pixels[X, Y]) or $ff000000;
|
---|
57 | Inc(P);
|
---|
58 | end;
|
---|
59 | end;
|
---|
60 | BGRABitmap.InvalidateBitmap; // changed by direct access
|
---|
61 | BGRABitmap.Draw(Canvas, 0, 0, True);
|
---|
62 | end;
|
---|
63 |
|
---|
64 | end.
|
---|
65 |
|
---|