
//==================================================
//过程名：DrawImage
//作  用：限制图片尺寸
//参  数：(ImgD,x,y)
//==================================================

var flag=false; 
function DrawImage(ImgD,x,y){ 
var image=new Image(); 
image.src=ImgD.src; 

if(image.width>0 && image.height>0){ 
flag=true; 
if(x!=0 && y!=0){
if(image.width/image.height>= x/y){ 
if(image.width>x){ 
ImgD.width=x; 
ImgD.height=(image.height*x)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
/*ImgD.alt=image.width+"×"+image.height;*/ 
} 
else{ 
if(image.height>y){ 
ImgD.height=y; 
ImgD.width=(image.width*y)/image.height; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
/*ImgD.alt=image.width+"×"+image.height;*/ 
} 
} 
else{
if(x==0){
if(image.width>x){ 
ImgD.width=x; 
ImgD.height=(image.height*x)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
}
else{
if(image.height>y){ 
ImgD.height=y; 
ImgD.width=(image.width*y)/image.height; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
}
}
/*else{ 
ImgD.src=""; 
ImgD.alt="" 
}*/
} 
} 









