﻿function DrawImage(ImgD,WidthNum,HeightNum){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
flag=true; 
if(image.width/image.height>= WidthNum/WidthNum){ 
if(image.width>WidthNum){ 
ImgD.width=WidthNum; 
ImgD.height=(image.height*WidthNum)/image.width; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 

} 
else{ 
if(image.height>HeightNum){ 
ImgD.height=HeightNum; 
ImgD.width=(image.width*HeightNum)/image.height; 
}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 

} 
} 
} 