图象处理难题!如何让图片在IMAGE里,按等高、等宽和100%三种方式显示??? IMAGE不能加滚动条,要把它方在TScrollBox控件上。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 100% image.autosize := true; 100% image.autosize := true; 等高: Image1.AutoSize :=false; Image1.Width :=Image1.Height ; Image1.Stretch :=true;等宽: Image1.AutoSize :=false; Image1.Height:=Image1.Width ; Image1.Stretch :=true;100%: Image1.Stretch:=false; Image1.AutoSize:=True; To Apollo47(阿波罗): 再请教一下,按你的方法确实解决了一部分问题,可是如何让图片在等高的前提下,其宽度按比例缩放显示呢??即:图片的宽、高比例依然不变,想ACDSEE那样。 通过Image.Picture的宽度与高度,自己计算。 例如:首先Image1.Stretch := True;procedure TForm1.btnHeightClick(Sender: TObject);begin Image1.Width := Round((Image1.Height / Image1.Picture.Height) * Image1.Picture.Width);end;procedure TForm1.btnWidthClick(Sender: TObject);begin Image1.Height := Round((Image1.Width / Image1.Picture.Width) * Image1.Picture.Height);end; 等高,等宽:image.autosize:=false;Image.Stretch:=True;100%:Image.Stretch:=false;另: 图片高(宽)超出IMAGE时,IMAGE如何自动加滚动条??将image控件放入frames中 ,且image.autosize:=true;Image.Stretch:=false; 更正:::::::::等高: Image1.AutoSize :=true; Image1.AutoSize :=false; Image1.Width(由你设) Image1.Stretch :=true;等宽: Image1.AutoSize :=true; Image1.AutoSize :=false; Image1.hight(由你设) Image1.Stretch :=true;100%:Image.Stretch:=false;另: 图片高(宽)超出IMAGE时,IMAGE如何自动加滚动条??将image控件放入frames中 ,且image.autosize:=true;Image.Stretch:=false; ------想ACDSEE那样--------应该是根据给定的区域大小,自动变化图像大小,且显示在区域中央我写了一下下面的函数,可以达到AcdSee中的效果//让图像显示在面版pnlPicture的中央procedure TfrmPicure.btnShowInPanelClick(Sender: TObject);var HeightRatio, WidthRatio: Double;begin //分别取得高度、宽度与显示区域的比例 HeightRatio := Image1.Picture.Height / pnlPicture.Height; WidthRatio := Image1.Picture.Width / pnlPicture.Width; //图像大于pnlPicture区域 if (HeightRatio > 1) or (WidthRatio > 1) then begin Image1.AutoSize := False; //若高度比例大于宽度比例,则缩放宽度 if HeightRatio > WidthRatio then begin //高度与pnlPicture一致 Image1.Top := pnlPicture.Top; Image1.Height := pnlPicture.Height; //变化其宽度,并显示在中间 Image1.Width := Round(Image1.Picture.Width / HeightRatio); Image1.Left := pnlPicture.Left + (pnlPicture.Width - Image1.Width) div 2; end else //若高度比例小于宽度比例,则缩放高度 begin Image1.Left := pnlPicture.Left; Image1.Width := pnlPicture.Width; Image1.Height := Round(Image1.Picture.Height / WidthRatio); Image1.Top := pnlPicture.Top + (pnlPicture.Height - Image1.Height) div 2; end; end //图像可以在pnlPicture区域完整显示,即图像小于pnlPicture区域 else begin Image1.AutoSize := True; //显示在正中央 Image1.Top := pnlPicture.Top + (pnlPicture.Height - Image1.Height) div 2; Image1.Left := pnlPicture.Left + (pnlPicture.Width - Image1.Width) div 2; end;end; 只要你做了,就有分了,谢谢大家帮忙了 请教怎样在listview的header上绘图? dll中的函数如何返回字符串??? StringGrid控件如何删除一行啊? 如何打印DBgrid 给几个字符串函数 请问如何判断报表打印的页数? adoquery的删除问题? 急求(购买)超市信息管理系统:Delphi+sql2000 Delphi 调用vb写的Dll窗口出现:“不能在该主机应用程序中从 ActiveX DLL、ActiveX 控件或“属性页”显示非模式窗体" 用DCOM构建三层分布式应用程序,连接不上. 怎样将 TImage 中装载的 Picture 释放掉
Image1.AutoSize :=false;
Image1.Width :=Image1.Height ;
Image1.Stretch :=true;
等宽:
Image1.AutoSize :=false;
Image1.Height:=Image1.Width ;
Image1.Stretch :=true;
100%:
Image1.Stretch:=false;
Image1.AutoSize:=True;
首先Image1.Stretch := True;procedure TForm1.btnHeightClick(Sender: TObject);
begin
Image1.Width := Round((Image1.Height / Image1.Picture.Height) * Image1.Picture.Width);
end;procedure TForm1.btnWidthClick(Sender: TObject);
begin
Image1.Height := Round((Image1.Width / Image1.Picture.Width) * Image1.Picture.Height);
end;
image.autosize:=false;
Image.Stretch:=True;
100%:Image.Stretch:=false;
另: 图片高(宽)超出IMAGE时,IMAGE如何自动加滚动条??
将image控件放入frames中 ,且
image.autosize:=true;
Image.Stretch:=false;
等高:
Image1.AutoSize :=true;
Image1.AutoSize :=false;
Image1.Width(由你设)
Image1.Stretch :=true;
等宽:
Image1.AutoSize :=true;
Image1.AutoSize :=false;
Image1.hight(由你设)
Image1.Stretch :=true;
100%:Image.Stretch:=false;
另: 图片高(宽)超出IMAGE时,IMAGE如何自动加滚动条??
将image控件放入frames中 ,且
image.autosize:=true;
Image.Stretch:=false;
应该是根据给定的区域大小,自动变化图像大小,且显示在区域中央
我写了一下下面的函数,可以达到AcdSee中的效果//让图像显示在面版pnlPicture的中央
procedure TfrmPicure.btnShowInPanelClick(Sender: TObject);
var
HeightRatio, WidthRatio: Double;
begin
//分别取得高度、宽度与显示区域的比例
HeightRatio := Image1.Picture.Height / pnlPicture.Height;
WidthRatio := Image1.Picture.Width / pnlPicture.Width;
//图像大于pnlPicture区域
if (HeightRatio > 1) or (WidthRatio > 1) then
begin
Image1.AutoSize := False;
//若高度比例大于宽度比例,则缩放宽度
if HeightRatio > WidthRatio then
begin
//高度与pnlPicture一致
Image1.Top := pnlPicture.Top;
Image1.Height := pnlPicture.Height;
//变化其宽度,并显示在中间
Image1.Width := Round(Image1.Picture.Width / HeightRatio);
Image1.Left := pnlPicture.Left + (pnlPicture.Width - Image1.Width) div 2;
end
else
//若高度比例小于宽度比例,则缩放高度
begin
Image1.Left := pnlPicture.Left;
Image1.Width := pnlPicture.Width;
Image1.Height := Round(Image1.Picture.Height / WidthRatio);
Image1.Top := pnlPicture.Top + (pnlPicture.Height - Image1.Height) div 2;
end;
end
//图像可以在pnlPicture区域完整显示,即图像小于pnlPicture区域
else
begin
Image1.AutoSize := True;
//显示在正中央
Image1.Top := pnlPicture.Top + (pnlPicture.Height - Image1.Height) div 2;
Image1.Left := pnlPicture.Left + (pnlPicture.Width - Image1.Width) div 2;
end;
end;