Html.js
上传用户:mtjhgs
上传日期:2021-12-08
资源大小:3755k
文件大小:1k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. function DrawImage(MyPic,W,H){
  2.   var flag=false;
  3.   var image=new Image();
  4.   image.src=MyPic.src;
  5.   if(image.width>0 && image.height>0){
  6.     flag=true;
  7.     if(image.width/image.height>= W/H){
  8.       if(image.width>W){
  9.         MyPic.width=W;
  10.         MyPic.height=(image.height*W)/image.width;
  11.       }
  12.   else{
  13.         MyPic.width=image.width;
  14.         MyPic.height=image.height;
  15.       }
  16.     }
  17.     else{
  18.       if(image.height>H){
  19.         MyPic.height=H;
  20.         MyPic.width=(image.width*H)/image.height;
  21.       }
  22.   else{
  23.         MyPic.width=image.width;
  24.         MyPic.height=image.height;
  25.       }
  26.     }
  27.   }
  28. }