Delphi-Quellcode:
ScaleX := AControlWidth / AMediaWidth;
ScaleY := AControlHeight / AMediaHeight;
if ScaleX >= ScaleY then
begin
// Result.Width := Round(AMediaWidth * ScaleY);
Result.Width := Round((AMediaWidth / AMediaHeight) * AControlHeight);
Result.Height := AControlHeight;
end
else
begin
Result.Width := AControlWidth;
Result.Height := Round((AMediaHeight / AMediaWidth) * AControlWidth);
// Result.Height := Round(AMediaHeight * ScaleX);
end;
Samples:
1920, 1080, 1366, 768 = 1365, 768
1366, 768, 1920, 1080 = 1920, 1079
So, in both variants (commented and not) result is the same (code based on GR32.GetBitmapSize) - is one line not enough in width or height. How to fix it? Something like add one and check range?