hi All,
i started working with bitmaps and got into issues at the code below.
basically i loaded some images into a images list and want to push to a TImage a stretched version so it fits the TImage dimensions.
please advise what i can do so buffer2 saves as original image stretched but not on black (like film negative).
unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
ImageList1: TImageList;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.Button1Click(Sender: TObject);
var
buffer1: TBitmap;
buffer2: TBitmap;
begin
try
buffer1 := TBitmap.Create;
buffer2 := TBitmap.Create;
ImageList1.GetBitmap(0, buffer1);
buffer1.SaveToFile('buff1.bmp');
buffer2.SetSize(Image1.Width, Image1.Height);
buffer2.Canvas.StretchDraw(Rect(0, 0, Image1.Width, Image1.Height), buffer1);
buffer2.SaveToFile('buff2.bmp');
Image1.Canvas.Clear;
Image1.Canvas.Draw(0, 0, buffer2);
finally
FreeAndNil(buffer1);
FreeAndNil(buffer2);
end;
end;
end.
thank you
Lazarus 1.8RC4, cross platform