image怎样按比例显示一幅图片

hansonboy 2004-06-15 12:40:22
一图片很大时,image正常不能全部显示,怎样按比例宿少图片再显示呢?
...全文
245 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cduck 2004-06-15
  • 打赏
  • 举报
回复
上面的函数应该可以实现这个功能

我简单的解释一下函数思想吧 完了你可以自己改或写

IF 图片高>image高 or 图片宽>image宽
begin
图片高=image高 图片宽=图片宽 X (image高/图片高)
end;
liuqifeiyu 2004-06-15
  • 打赏
  • 举报
回复
nihongjiang(jacky-ni) 的代码启示:
如果那样行的话为什么不改成这样呢?:
begin

image1.Stretch :=true;
image1.Picture.Width:=image1.width;
image1.Picture.Height:=image1.heigth;

end; 这段函数应该能满足你的要求

hansonboy 2004-06-15
  • 打赏
  • 举报
回复
谢谢,搞好了,是整数跟实数的错误
hansonboy 2004-06-15
  • 打赏
  • 举报
回复
image1.Height :=image1.Picture.Height / xx;

这里出错了
zgq19801123 2004-06-15
  • 打赏
  • 举报
回复
up
nihongjiang 2004-06-15
  • 打赏
  • 举报
回复
var
hh,ww,xx:real;
begin
hh:=236; //image的高度
ww:=188; //image的宽度
if (hh < image1.Picture.Height) or (ww < image1.Picture.Width) then
begin
image1.Stretch :=true;
if (hh / image1.Picture.Height) < (ww / image1.Picture.Width) then
xx:= image1.Picture.Height / hh
else
xx:=image1.Picture.Width / ww;

image1.Height :=image1.Picture.Height / xx;
image1.width :=image1.Picture.width / xx;
end
else
begin
image1.Height :=hh;
image1.Width :=ww;
image1.Stretch :=false;
end;
end; 这段函数应该能满足你的要求
hansonboy 2004-06-15
  • 打赏
  • 举报
回复
怎样做呢?
JJNW 2004-06-15
  • 打赏
  • 举报
回复
楼上的是“拉伸”,不是按比例缩放
搂主自己写函数吧
江宁侯哥 2004-06-15
  • 打赏
  • 举报
回复
Image1.Stretch :=true;
hansonboy 2004-06-15
  • 打赏
  • 举报
回复
没人知道吗?

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧