source: GraphicTest/Methods/MethodBGRABitmap.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: 1.4 KB
Line 
1unit MethodBGRABitmap;
2
3interface
4
5uses
6 Classes, SysUtils, DrawMethod, FastBitmap, BGRABitmap, BGRABitmapTypes,
7 Controls, Graphics;
8
9type
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
21implementation
22
23{ TMethodBGRABitmap }
24
25procedure TMethodBGRABitmap.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
26begin
27 inherited;
28 BGRABitmap.SetSize(Size.X, Size.Y);
29end;
30
31constructor TMethodBGRABitmap.Create;
32begin
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.');
39end;
40
41destructor TMethodBGRABitmap.Destroy;
42begin
43 BGRABitmap.Free;
44 inherited;
45end;
46
47procedure TMethodBGRABitmap.DrawFrame(FastBitmap: TFastBitmap);
48var
49 X, Y: Integer;
50 P: PCardinal;
51begin
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);
62end;
63
64end.
65
Note: See TracBrowser for help on using the repository browser.