source: trunk/Methods/UMethodLazIntfImageColorsNoCopy.pas

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