source: GraphicTest/Methods/MethodGraphics32.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: 2.3 KB
Line 
1unit MethodGraphics32;
2
3interface
4
5uses
6 Classes, SysUtils, FastBitmap, DrawMethod,
7 {$IFDEF GRAPHICS32}GR32, GR32_Image,{$ENDIF}
8 Controls, Graphics;
9
10{$IFDEF GRAPHICS32}
11type
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
24implementation
25
26{$IFDEF GRAPHICS32}
27{ TMethodGraphics32 }
28
29constructor TMethodGraphics32.Create;
30begin
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;');
42end;
43
44destructor TMethodGraphics32.Destroy;
45begin
46 inherited;
47end;
48
49procedure TMethodGraphics32.DrawFrame(FastBitmap: TFastBitmap);
50var
51 Y, X: Integer;
52 PixelPtr: PColor32;
53 RowPtr: PColor32;
54 ImagePtr: PColor32;
55 BytePerPixel: Integer;
56 BytePerRow: Integer;
57begin
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;
77end;
78
79procedure TMethodGraphics32.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
80begin
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;
87end;
88
89procedure TMethodGraphics32.Done;
90begin
91 FreeAndNil(Image);
92 inherited;
93end;
94
95{$ENDIF}
96
97end.
98
Note: See TracBrowser for help on using the repository browser.