source: GraphicTest/Methods/MethodLazIntfImageColorsNoCopy.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.6 KB
Line 
1unit MethodLazIntfImageColorsNoCopy;
2
3interface
4
5uses
6 Classes, SysUtils, DrawMethod, FastBitmap, IntfGraphics, Graphics, Controls;
7
8type
9 { TMethodLazIntfImageColorsNoCopy }
10
11 TMethodLazIntfImageColorsNoCopy = class(TDrawMethodImage)
12 TempIntfImage: TLazIntfImage;
13 procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override;
14 constructor Create; override;
15 destructor Destroy; override;
16 procedure DrawFrame(FastBitmap: TFastBitmap); override;
17 end;
18
19
20implementation
21
22{ TMethodLazIntfImageColorsNoCopy }
23
24procedure TMethodLazIntfImageColorsNoCopy.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
25begin
26 inherited;
27 TempIntfImage.Free;
28 TempIntfImage := Image.Picture.Bitmap.CreateIntfImage;
29end;
30
31constructor TMethodLazIntfImageColorsNoCopy.Create;
32begin
33 inherited;
34 Caption := 'TLazIntfImage.Colors no copy';
35 Description.Add('Method use TLazIntfImage class for faster access to bitmap pixels compared to simple access using TBitmap.Pixels.');
36 Description.Add('Bitmap is not copied from original bitmap.');
37end;
38
39destructor TMethodLazIntfImageColorsNoCopy.Destroy;
40begin
41 TempIntfImage.Free;
42 inherited;
43end;
44
45procedure TMethodLazIntfImageColorsNoCopy.DrawFrame(FastBitmap: TFastBitmap);
46var
47 Y, X: Integer;
48begin
49 with FastBitmap do begin
50 for X := 0 to Size.X - 1 do
51 for Y := 0 to Size.Y - 1 do
52 TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));
53 Image.Picture.Bitmap.LoadFromIntfImage(TempIntfImage);
54 end;
55end;
56
57end.
58
Note: See TracBrowser for help on using the repository browser.