1 | unit MethodGraphics32;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FastBitmap, DrawMethod,
|
---|
7 | {$IFDEF GRAPHICS32}GR32, GR32_Image,{$ENDIF}
|
---|
8 | Controls, Graphics;
|
---|
9 |
|
---|
10 | {$IFDEF GRAPHICS32}
|
---|
11 | type
|
---|
12 | { TMethodGraphics32 }
|
---|
13 |
|
---|
14 | TMethodGraphics32 = class(TDrawMethod)
|
---|
15 | Image: TImage32;
|
---|
16 | constructor Create; override;
|
---|
17 | destructor Destroy; override;
|
---|
18 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
---|
19 | procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override;
|
---|
20 | procedure Done; override;
|
---|
21 | end;
|
---|
22 | {$ENDIF}
|
---|
23 |
|
---|
24 | implementation
|
---|
25 |
|
---|
26 | {$IFDEF GRAPHICS32}
|
---|
27 | { TMethodGraphics32 }
|
---|
28 |
|
---|
29 | constructor TMethodGraphics32.Create;
|
---|
30 | begin
|
---|
31 | inherited;
|
---|
32 | Caption := 'TGR32Image';
|
---|
33 | Description.Add('Graphics32 is well implemented highly optimized Delphi graphic ' +
|
---|
34 | 'library also ported to Lazarus/LCL. It uses static 32-bit wide pixel:');
|
---|
35 | Description.Add('TColor32Entry = packed record');
|
---|
36 | Description.Add(' case Integer of');
|
---|
37 | Description.Add(' 0: (B, G, R, A: Byte);');
|
---|
38 | Description.Add(' 1: (ARGB: TColor32);');
|
---|
39 | Description.Add(' 2: (Planes: array[0..3] of Byte);');
|
---|
40 | Description.Add(' 3: (Components: array[TColor32Component] of Byte);');
|
---|
41 | Description.Add('end;');
|
---|
42 | end;
|
---|
43 |
|
---|
44 | destructor TMethodGraphics32.Destroy;
|
---|
45 | begin
|
---|
46 | inherited;
|
---|
47 | end;
|
---|
48 |
|
---|
49 | procedure TMethodGraphics32.DrawFrame(FastBitmap: TFastBitmap);
|
---|
50 | var
|
---|
51 | Y, X: Integer;
|
---|
52 | PixelPtr: PColor32;
|
---|
53 | RowPtr: PColor32;
|
---|
54 | ImagePtr: PColor32;
|
---|
55 | BytePerPixel: Integer;
|
---|
56 | BytePerRow: Integer;
|
---|
57 | begin
|
---|
58 | with FastBitmap do
|
---|
59 | try
|
---|
60 | Image.Bitmap.BeginUpdate;
|
---|
61 | BytePerPixel := 4;
|
---|
62 | BytePerRow := 4 * Image.Bitmap.Width;
|
---|
63 | ImagePtr := Image.Bitmap.PixelPtr[0, 0];
|
---|
64 | RowPtr := ImagePtr;
|
---|
65 | for Y := 0 to Size.Y - 1 do begin
|
---|
66 | PixelPtr := RowPtr;
|
---|
67 | for X := 0 to Size.X - 1 do begin
|
---|
68 | PixelPtr^ := Pixels[X, Y];
|
---|
69 | Inc(PByte(PixelPtr), BytePerPixel);
|
---|
70 | end;
|
---|
71 | Inc(PByte(RowPtr), BytePerRow);
|
---|
72 | end;
|
---|
73 | finally
|
---|
74 | Image.Bitmap.EndUpdate;
|
---|
75 | end;
|
---|
76 | Image.Repaint;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TMethodGraphics32.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
|
---|
80 | begin
|
---|
81 | inherited;
|
---|
82 | Image := TImage32.Create(Parent);
|
---|
83 | Image.Parent := Parent;
|
---|
84 | Image.SetBounds(0, 0, Size.X, Size.Y);
|
---|
85 | Image.Bitmap.SetSize(Size.X, Size.Y);
|
---|
86 | Image.Show;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TMethodGraphics32.Done;
|
---|
90 | begin
|
---|
91 | FreeAndNil(Image);
|
---|
92 | inherited;
|
---|
93 | end;
|
---|
94 |
|
---|
95 | {$ENDIF}
|
---|
96 |
|
---|
97 | end.
|
---|
98 |
|
---|