Resize graphic proportionally lazarus / 39-Graphics ---------------------------------------------------------------------- vonskie · 2018-02-09 21:04 What am I doing wrong here? If bmp.width =< then it works okay If bmp.width > does not scale correctly What am I doing wrong? if (checkboxresize.Checked) then         begin            if bmp.Width > bmp.Height then           begin             bmp.ResampleFilter := rfBestQuality;             BGRAReplace(bmp,             // bmp.resample(width,height)             bmp.Resample(screen.width,(screen.Width * bmp.Height) div bmp.Width) as TBGRABitmap);            end           else           begin                       bmp.ResampleFilter := rfBestQuality;             BGRAReplace(BMP,             bmp.resample((screen.Height * bmp.Width) div bmp.Height,screen.height) as TBGRABitmap);           end; ---------------------------------------------------------------------- vonskie · 2018-02-10 01:05 Here is a way that works if (resizechecked) then                 begin                   ratioX := screen.width / bmp.Width;                   ratioY := screen.Height / bmp.Height;                   ratio := Min(ratioX, ratioY);                   newWidth := trunc(bmp.Width * ratio);                   newHeight := trunc(bmp.Height * ratio);                   bmp.ResampleFilter := rfBestQuality;                    BGRAReplace(BMP, bmp.resample(newwidth,newheight)  as                       TBGRABitmap);                 end;