威尼斯赌博游戏

图片比例缩放图片缩放

来源: www.zngps.com| 2018-06-07 11:07
<SCRIPT LANGUAGE="JavaScript"> 
<!--
//图片等比例缩放

var FitWidth = 220;  //图片宽度
var FitHeight = 220; //图片高度
function ResizePic(ImgTag)
{
    var image = new Image();
 image.src = ImgTag.src;
 if(image.width>0 && image.height>0){
  if(image.width/image.height >= FitWidth/FitHeight){
   if(image.width > FitWidth){
    ImgTag.width = FitWidth;
    ImgTag.height = (image.height*FitWidth)/image.width;
   }
   else{ 
    ImgTag.width = image.width;
    ImgTag.height = image.height;
   }
  }
  else{
   if(image.height > FitHeight){
    ImgTag.height = FitHeight;
    ImgTag.width = (image.width*FitHeight)/image.height;
   }
   else{
    ImgTag.width = image.width; 
    ImgTag.height = image.height;
   }
  }
 }
}
-->
</script>

猜你喜欢
推荐
随机推荐
相关文档
Top
Baidu