[Lazarus] How to save screenshot to jpg and png format files

Bo Berglund bo.berglund at gmail.com
Fri Apr 30 10:17:19 CEST 2021

On Thu, 29 Apr 2021 16:49:06 +0000, Patrick Chevalley via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>Replace :
>MyCapture.Bitmap.SaveToFile(ChangeFileExt(ParamStr(0), '.jpg'));
>by :
>MyCapture.SaveToFile(ChangeFileExt(ParamStr(0), '.jpg'));
>This work because Bgrabitmap set automatically the image writer based on the extension. 

I could remove *all* the extra code I had added to create jpg, png and bmp
containers. Instead I could save directly from the MyCapture object, which has
built-in magic to save files correctly based on the commonly used extesnions in
the file name.

Problem solved, thanks!

Bo Berglund
Developer in Sweden

More information about the lazarus mailing list