Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2014-03

Saving TImage Bitmap as shown

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nathan Wild

Is there any way to tell a TImage to save it's Bitmap as-shown? I need to do some relatively simple image resizing in order to ensure images display properly in another application. To do this they need to be a fixed size (512x768), but I need to preserve their aspect ratio by adding padding to the top, bottom and sides, as required.

For example, if my source image is 100x100, I can scale it up to 512x512 easily enough, but I need have the end result image be 512x768 with padding (solid colour, etc.) at the top and bottom to ensure it is centred.

If you take a TImage control, load the 100x100 example image, set:
Width := 512;
Height := 768;
Centered := TRUE;
Proportional := TRUE;
Stretch := TRUE;

The image it contains will display in exactly the way I am after. I am just not sure how to tell the TImage to save THAT image.

Thanks for any help...

*Nathan T. Wild*

Reply by email