Einzelnen Beitrag anzeigen

Benutzerbild von S - tefano
S - tefano

Registriert seit: 16. Dez 2002
Ort: Dülmen
477 Beiträge
 
Delphi 2009 Professional
 
#2

Re: GR32: TImage32 in den Hintergrund

  Alt 9. Okt 2008, 11:44
Ich hatte mich geirrt, zum einen bietet TImage ein smScaledOptimal-Pendant an (proportional=true, stretch=false), zum anderen kann man im TImage aber nicht die Größe der u.U. verkleinerten Bitmap anzeigen lassen.
Habe mir das mal mit einer Methode gemacht. Wens interessiert:

Delphi-Quellcode:
function getBildSeitenVerhaeltnis(x, y: integer): double;
begin
  result:= Max(x, y) / Min(x, y);
end;

function getDisplayedImageSize(image: TImage): TPoint;
var
  quot: double;
begin
  quot:= getBildSeitenVerhaeltnis(image.Picture.Width, image.Picture.Height);
  result.X:= 0;
  result.Y:= 0;
  if (Max(image.Picture.Width, image.Picture.Height) <= Max(image.Width, image.Height)) then begin
    result.X:= image.Picture.Width;
    result.Y:= image.Picture.Height;
  end
  else begin
    if (image.Picture.Width >= image.Picture.Height) then begin
      result.X:= image.Width;
      result.Y:= round(image.Width / quot);
    end
    else begin
      result.Y:= image.Height;
      result.X:= round(image.Height / quot);
    end;
  end;
end;
"Sir, we are surrounded!" - "Excellent, we can attack in every direction!"
  Mit Zitat antworten Zitat