ImageEn, unit hyieutils



function GetImageSizeWithinArea(ImgWidth, ImgHeight : integer;
                                DestWidth, DestHeight : integer;
                                bAllowStretching : boolean = TRUE;
                                FitMethod: TFitMethod = _fmFitWithinRect
                                ): TPoint;


Return the new size of an image we wish to fit within an area of size DestWidth x DestHeight while maintaining the original aspect ratio

Parameter Description
ImgWidth, ImgHeight The dimensions of the image
DestWidth, DestHeight The space available for the image (e.g. the client area of a display control, such as a TImageEnView)
bAllowStretching If the image is smaller than the available area it will be stretched to the full available size (otherwise result is the original width/height)
FitMethod Generally _fmFitWithinRect, but _fmFillRect_WithOverlap will return an image that makes the image as large as possible without any border area (so one dimension will match the available size, and the other will generally be larger)


// We want size for a thumbnail no larger than 100x100, but at same aspect ratio as source image
sz := GetImageSizeWithinArea( SrcBMP.Width, SrcBMP.Height, 100, 100 );

See Also

- GetImageRectWithinArea
- IEAdjustRectToAspectRatio