function DrawImage(ImgD,w,h){
   xwidth=w;
   xheight=h;
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= xwidth/xheight){
     if(image.width>xwidth){  
     ImgD.width=xwidth;
     ImgD.height=(image.height*xwidth)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    else{
     if(image.height>xheight){  
     ImgD.height=xheight;
     ImgD.width=(image.width*xheight)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    }
}
