//图片按比例缩放
var flag=false;
function DrawImage(ImgD,ImgW,ImgH){
 var image=new Image();
 var iwidth = ImgW;  //定义允许图片宽度
 var iheight = ImgH;  //定义允许图片高度
 image.src=ImgD.src;
 if(image.width>0 && image.height>0){
 	var image_width = image.width;
 	var image_height = image.height;
 }
 else
 {
 	var image_width = ImgD.offsetWidth;
 	var image_height = ImgD.offsetHeight;
 }
 if(image_width>0 && image_height>0)
 {
 	flag=true;
 	if(image_width/image_height>= iwidth/iheight)
 	{
 		if(image_width>iwidth){
 			ImgD.width=iwidth;
 			ImgD.height=(image_height*iwidth)/image_width;
 		}else{
 			ImgD.width=image_width;
 			ImgD.height=image_height;
 		}
 		ImgD.alt=image_width+"×"+image_height;
 	}
 	else{
 		if(image_height>iheight){
 			ImgD.height=iheight;
 			ImgD.width=(image_width*iheight)/image_height;
 		}else{
 			ImgD.width=image_width;
 			ImgD.height=image_height;
 		}
 		ImgD.alt=image_width+"×"+image_height;
 	}
 }
 else
 {
 	ImgD.width=ImgW;
 	ImgD.height=ImgH;
 }
}
//图片按比例缩放結束

