Html.js
资源名称:1.rar [点击查看]
上传用户:yrf020
上传日期:2007-07-24
资源大小:1287k
文件大小:1k
源码类别:

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

开发平台:

HTML/CSS

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