source: trunk/Methods/UMethodBGRABitmap.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 1.5 KB
Line 
1unit UMethodBGRABitmap;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UDrawMethod, UFastBitmap, BGRABitmap, BGRABitmapTypes,
9 Controls, Graphics;
10
11type
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
23implementation
24
25{ TMethodBGRABitmap }
26
27procedure TMethodBGRABitmap.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
28begin
29 inherited;
30 BGRABitmap.SetSize(Size.X, Size.Y);
31end;
32
33constructor TMethodBGRABitmap.Create;
34begin
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.');
41end;
42
43destructor TMethodBGRABitmap.Destroy;
44begin
45 BGRABitmap.Free;
46 inherited Destroy;
47end;
48
49procedure TMethodBGRABitmap.DrawFrame(FastBitmap: TFastBitmap);
50var
51 X, Y: Integer;
52 P: PCardinal;
53begin
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);
64end;
65
66
67end.
68
Note: See TracBrowser for help on using the repository browser.