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