| 1 | unit UMethodLazIntfImageColorsCopy;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, UDrawMethod, UFastBitmap, IntfGraphics, GraphType,
|
|---|
| 9 | fpImage, Graphics;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 | { TMethodLazIntfImageColorsCopy }
|
|---|
| 13 |
|
|---|
| 14 | TMethodLazIntfImageColorsCopy = class(TDrawMethodImage)
|
|---|
| 15 | constructor Create; override;
|
|---|
| 16 | destructor Destroy; override;
|
|---|
| 17 | procedure DrawFrame(FastBitmap: TFastBitmap); override;
|
|---|
| 18 | end;
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | implementation
|
|---|
| 22 |
|
|---|
| 23 | { TMethodLazIntfImageColorsCopy }
|
|---|
| 24 |
|
|---|
| 25 | constructor TMethodLazIntfImageColorsCopy.Create;
|
|---|
| 26 | begin
|
|---|
| 27 | inherited;
|
|---|
| 28 | Caption := 'TLazIntfImage.Colors copy';
|
|---|
| 29 | Description.Add('Method use TLazIntfImage class for faster access to bitmap pixels compared to simple access using TBitmap.Pixels.');
|
|---|
| 30 | Description.Add('TLazIntfImage is created from visible image.');
|
|---|
| 31 | end;
|
|---|
| 32 |
|
|---|
| 33 | destructor TMethodLazIntfImageColorsCopy.Destroy;
|
|---|
| 34 | begin
|
|---|
| 35 | inherited Destroy;
|
|---|
| 36 | end;
|
|---|
| 37 |
|
|---|
| 38 | procedure TMethodLazIntfImageColorsCopy.DrawFrame(FastBitmap: TFastBitmap);
|
|---|
| 39 | var
|
|---|
| 40 | Y, X: Integer;
|
|---|
| 41 | TempIntfImage: TLazIntfImage;
|
|---|
| 42 | begin
|
|---|
| 43 | with FastBitmap do begin
|
|---|
| 44 | TempIntfImage := TLazIntfImage.Create(Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height);
|
|---|
| 45 | TempIntfImage.LoadFromBitmap(Image.Picture.Bitmap.Handle,
|
|---|
| 46 | Image.Picture.Bitmap.MaskHandle);
|
|---|
| 47 | for X := 0 to Size.X - 1 do
|
|---|
| 48 | for Y := 0 to Size.Y - 1 do
|
|---|
| 49 | TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));
|
|---|
| 50 | Image.Picture.Bitmap.LoadFromIntfImage(TempIntfImage);
|
|---|
| 51 | TempIntfImage.Free;
|
|---|
| 52 | end;
|
|---|
| 53 | end;
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | end.
|
|---|
| 57 |
|
|---|