| 1 | unit MethodLazIntfImageColorsNoCopy;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, DrawMethod, FastBitmap, IntfGraphics, Graphics, Controls;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 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 |
|
|---|
| 20 | implementation
|
|---|
| 21 |
|
|---|
| 22 | { TMethodLazIntfImageColorsNoCopy }
|
|---|
| 23 |
|
|---|
| 24 | procedure TMethodLazIntfImageColorsNoCopy.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
|
|---|
| 25 | begin
|
|---|
| 26 | inherited;
|
|---|
| 27 | TempIntfImage.Free;
|
|---|
| 28 | TempIntfImage := Image.Picture.Bitmap.CreateIntfImage;
|
|---|
| 29 | end;
|
|---|
| 30 |
|
|---|
| 31 | constructor TMethodLazIntfImageColorsNoCopy.Create;
|
|---|
| 32 | begin
|
|---|
| 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.');
|
|---|
| 37 | end;
|
|---|
| 38 |
|
|---|
| 39 | destructor TMethodLazIntfImageColorsNoCopy.Destroy;
|
|---|
| 40 | begin
|
|---|
| 41 | TempIntfImage.Free;
|
|---|
| 42 | inherited;
|
|---|
| 43 | end;
|
|---|
| 44 |
|
|---|
| 45 | procedure TMethodLazIntfImageColorsNoCopy.DrawFrame(FastBitmap: TFastBitmap);
|
|---|
| 46 | var
|
|---|
| 47 | Y, X: Integer;
|
|---|
| 48 | begin
|
|---|
| 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;
|
|---|
| 55 | end;
|
|---|
| 56 |
|
|---|
| 57 | end.
|
|---|
| 58 |
|
|---|