Hello Lazarus Community,
this is my first post, and i hope i get good help. I am very new to Lazarus and ObjPascal, please be kind if i do simple stuff wrong.
To the Problem i have i found nothing in the Wiki nor the Forum.
I am currently doing experiments with BGRABitmap. I simply want to load an image from the clipboard and put it into a TBGRABitmap variable. Later i want to do something with this image, but in my test Code i want to show the TBGRABitmap variable in an Timage on the Form.
this is my current button function:
procedure TForm1.btnClipboardClick(Sender: TObject);
var
image : TBGRABitmap;
pic : TPicture;
begin
try
try
//initialize
pic := TPicture.Create();
if (Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap))) then
begin
pic.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfBitmap));
image := TBGRABitmap.Create(pic.bitmap);
Image1.Picture.Assign(image);
Image2.Picture.Assign(pic.Bitmap);
end
else if (Clipboard.HasFormat(PredefinedClipboardFormat(pcfPicture))) then
begin
pic.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfPicture));
image := TBGRABitmap.Create(pic.Bitmap);
Image1.Picture.Assign(image);
Image2.Picture.Assign(pic.Bitmap);
end;
finally
try
pic.Free;
//image.free
except
on E : Exception do ShowMessage(E.Message);
end;
end;
except
on E : Exception do ShowMessage(E.Message);
end;
end;
Image1 on the Form looks corrupted, Image2 fine (see attachment). The Error appears in Windows, in Linux it works fine. What am i doing wrong?