精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● Delphi>>图形界面和窗体>>图形图象>>提供一个适当显示图像的方法

主题:提供一个适当显示图像的方法
发信人: asynce()
整理人: soaringbird(2002-01-16 09:59:43), 站内信件
功能是看见全图但不变形

image1的strech是true

procedure LoadPic(S:string);
var x,y:integer;
    xscale,yscale:real;
begin
  Image1.Picture:=nil;
  if fileexists(S) then
  Image1.Picture.LoadFromFile(S);

  x:=image1.Picture.Width;
  y:=image1.Picture.Height;

  xscale:=x/321;   //321为image1的设计显示宽度
  yscale:=y/225;   //225为image1的设计显示高度
  if xscale>yscale then begin
    image1.Width:=321;
    image1.Height:=trunc(y/xscale);
  end
  else begin
    image1.Width:=trunc(x/yscale);
    image1.Height:=225;
  end;
end;

[关闭][返回]