var  flag=false;
function  DrawImage(ImgD,p_width,p_height){
     var  image=new  Image();
     image.src=ImgD.src;
     //需要的最大宽度
     var needwidth=p_width;
     //需要的最大高度
     var needheight=p_height;
     if(image.width>0  &&  image.height>0){
       flag=true;
       if(image.width/image.height>=  needwidth/needheight){
         if(image.width>needwidth){
         ImgD.width=needwidth;
         ImgD.height=(image.height*needwidth)/image.width;
         }else{
         ImgD.width=image.width;
         ImgD.height=image.height;
         }

         }
       else{
         if(image.height>needheight){
         ImgD.height=needheight;
         ImgD.width=(image.width*needheight)/image.height;
         }else{
         ImgD.width=image.width;
         ImgD.height=image.height;
         }

         }
       }
}