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