AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Fit image in control

Ein Thema von WojTec · begonnen am 31. Jan 2017 · letzter Beitrag vom 1. Feb 2017
 
WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

Fit image in control

  Alt 31. Jan 2017, 20:51
Delphi-Version: 10 Berlin
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?
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz