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
Antwort Antwort
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.603 Beiträge
 
Delphi 12 Athens
 
#1

AW: Re: Fit image in control

  Alt 1. Feb 2017, 12:23
Yes, but in examples both ratios are 16:9, it shouldn't be streched (of course only in case if both has the same aspect ratio, for example HD/FullHD/UltraHD stream on wide screen)?
1366x768 is not precisely (as in floating precision of your CPU) 16:9. If it were, ScaleX and ScaleY would be equal in your example.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
WojTec

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

Re: Fit image in control

  Alt 1. Feb 2017, 15:05
Ok, I understand, thank you

But another question is, if above code is oke, why eg. Photoshop has different result for this data?
  Mit Zitat antworten Zitat
Benutzerbild von mikhal
mikhal

Registriert seit: 11. Sep 2003
Ort: Linz am Rhein
796 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: Fit image in control

  Alt 1. Feb 2017, 15:45
Could be a rounding error. Try another formula:

Result.Width := Round(AMediaWidth * AControlHeight / AMediaHeight);
and
Result.Height := Round(AMediaHeight * AControlWidth / AMediaWidth);
Your Version defines a small result in your term to round, leading to a possible inaccuracy with your following multipication.

Second: Round uses Banker's Rounding. If your term to round is in the middle of two numbers it will give you the even number.

Gretings
Mikhal
Michael Kraemer
Computer erleichtern die Arbeit...
...und die Erde ist eine Scheibe!
  Mit Zitat antworten Zitat
WojTec

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

Re: Fit image in control

  Alt 1. Feb 2017, 16:28
Also returns one line not enough
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.603 Beiträge
 
Delphi 12 Athens
 
#5

AW: Re: Fit image in control

  Alt 1. Feb 2017, 17:01
But another question is, if above code is oke, why eg. Photoshop has different result for this data?
Probably because PS does it different.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
WojTec

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

Re: Fit image in control

  Alt 1. Feb 2017, 17:33
Yeah, what is different way to do this?
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.603 Beiträge
 
Delphi 12 Athens
 
#7

AW: Re: Fit image in control

  Alt 1. Feb 2017, 18:00
Yeah, what is different way to do this?
Perhaps something like:

Delphi-Quellcode:
if <ScaleX is almost the same as ScaleY> then begin
  Result.Width := AControlWidth;
  Result.Height := AControlHeight;
end
else begin
  < original code >
end;
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Antwort Antwort


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 03:59 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