请问在ASP怎么让图片按比例显示出来?

来源:百度知道 编辑:UC知道 时间:2024/05/22 01:24:13
请问在ASP怎么让图片按比例显示出来,也就是说,一个图像占位符固定大小,但是显示图片的时候,我要图片按比例显示!!!!
可以看看这个网站的图片...
图片好像是成比例显示出来的.
http://www.coloryworld.com/Product.asp

先装个aspjpeg组件,然后用这个函数,以占位固定120*120为例
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 120/120){
if(image.width>120){
ImgD.width=120;
ImgD.height=(image.height*120)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>120){
ImgD.height=120;
ImgD.width=(image.width*120)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}