1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| unit UCompImage;
{$mode delphi}
interface
uses
Classes, SysUtils, UDrawMethod, UFastBitmap, Graphics, GraphType, Controls, CompImages, LCLCompImages;
type
{ TBitmapRawImageData }
TCompImage = class(TDrawMethodImage)
TempImage: TCompactImage;
TempLCLImage: TLCLCompactImage;
constructor Create; override;
destructor Destroy; override;
procedure Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat); override;
procedure DrawFrame(FastBitmap: TFastBitmap); override;
end;
implementation
{ TBitmapRawImageData }
constructor TCompImage.Create;
begin
inherited;
Caption := 'TComp.Image';
Description.Add('Custom TFastBitmap data are converted to visible Comp image bitmap. ' +
'Then Canvas is responsible for show loaded data.');
end;
procedure TCompImage.Init(Parent: TWinControl; Size: TPoint; PixelFormat: TPixelFormat);
begin
inherited;
TempImage := TCompactImage.Create(Size.X, Size.Y);
TempLCLImage := TLCLCompactImage.Create(TempImage);
//TempBitmap.PixelFormat := PixelFormat;
end;
// 1ere Methode
procedure TCompImage.DrawFrame(FastBitmap: TFastBitmap);
var
Y, X: Integer;
begin
with FastBitmap do
begin
for X := 0 to Size.X - 1 do
for Y := 0 to Size.Y - 1 do
TempImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));
end;
// TempLCLImage.DrawTo(Image.Canvas); ----> Ca ne fonctionne pas
// donc 1ere methode de transfert mais piouf que c'est long !!!!!
Image.Picture.Bitmap.Assign(TempLCLImage.ImageBitmap);
end;
destructor TCompImage.Destroy;
begin
TempImage.Free;
TempLCLImage.Free;
inherited Destroy;
end;
end. |
Partager