[Lazarus] How to save screenshot to jpg and png format files
Bo Berglund
bo.berglund at gmail.com
Thu Apr 29 17:49:43 CEST 2021
I have an application which can capture a regon of the desktop into an image.
It uses TBgraBitmap since it has a method for grabbing data from the screen.
So I can assign this to the clipboard and also save to a file:
var
MyCapture : TBgraBitmap;
Clip: TRect;
...
begin
...
Clip := Bounds(Self.Left, Self.Top, Self.Width, Self.Height);
MyCapture := TBgraBitmap.Create();
MyCapture.TakeScreenShot(Clip);
Clipboard.Assign(MyCapture.Bitmap);
MyCapture.Bitmap.SaveToFile(ChangeFileExt(ParamStr(0), '.jpg'));
MyCapture.Free;
...
end;
But the SaveToFile results in a file that is NOT a jpeg file at all...
How could I save it to a specific (known) format, like jpg or png?
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list