| 1 | unit UMethodLazIntfImageColorsNoCopy;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, UDrawMethod, UFastBitmap, IntfGraphics, Graphics, Controls;
|
|---|
| 9 |
|
|---|
| 10 | type
|
|---|
| 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 |
|
|---|
| 22 | implementation
|
|---|
| 23 |
|
|---|
| 24 | { TMethodLazIntfImageColorsNoCopy }
|
|---|
| 25 |
|
|---|
| 26 | procedure TMethodLazIntfImageColorsNoCopy.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
|
|---|
| 27 | begin
|
|---|
| 28 | inherited;
|
|---|
| 29 | TempIntfImage.Free;
|
|---|
| 30 | TempIntfImage := Image.Picture.Bitmap.CreateIntfImage;
|
|---|
| 31 | end;
|
|---|
| 32 |
|
|---|
| 33 | constructor TMethodLazIntfImageColorsNoCopy.Create;
|
|---|
| 34 | begin
|
|---|
| 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.');
|
|---|
| 39 | end;
|
|---|
| 40 |
|
|---|
| 41 | destructor TMethodLazIntfImageColorsNoCopy.Destroy;
|
|---|
| 42 | begin
|
|---|
| 43 | TempIntfImage.Free;
|
|---|
| 44 | inherited Destroy;
|
|---|
| 45 | end;
|
|---|
| 46 |
|
|---|
| 47 | procedure TMethodLazIntfImageColorsNoCopy.DrawFrame(FastBitmap: TFastBitmap);
|
|---|
| 48 | var
|
|---|
| 49 | Y, X: Integer;
|
|---|
| 50 | begin
|
|---|
| 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;
|
|---|
| 57 | end;
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | end.
|
|---|
| 61 |
|
|---|