zoukankan      html  css  js  c++  java
  • 图片等比缩放

    <img src="http://www.baidu.com/img/shouye_b5486898c692066bd2cbaeda86d74448.gif" border="0" onload="javascript:DrawImage(this,600,1520);"/>

    //***********************************
    // 函数名: DrawImage
    // 作  用: 缩放图片比例
    // 参  数: ImgD:图片项,Img设定宽度,Imgheight:设定高度
    // 返回值: 无
    //***********************************
    function DrawImage(ImgD,Imgwidth,Imgheight){
       var image=new Image();
       image.src=ImgD.src;
       if(image.width>0 && image.height>0){
        if(image.width/image.height>= Imgwidth/Imgheight){
       if(image.width>Imgwidth){ 
        ImgD.width=Imgwidth;
        ImgD.height=(image.height*Imgwidth)/image.width;
       }
       else{
        ImgD.width=image.width; 
        ImgD.height=image.height;
       }
       ImgD.alt=image.width+"×"+image.height;

         }
        else{
       if(image.height>Imgheight){ 
        ImgD.height=Imgheight;
        ImgD.width=(image.width*Imgheight)/image.height;    
       }
       else{
        ImgD.width=image.width; 
        ImgD.height=image.height;
       }

       ImgD.alt=image.width+"×"+image.height;
         }
        }
       else{
      ImgD.src="";
      ImgD.alt=""
        }
       }

  • 相关阅读:
    valgrind检查:Conditional jump or move depends on uninitialised value(s)
    信号 SIGPIPE
    Snapdragon——1.定位游戏瓶颈
    unity修改所选路径下的,对象的importer属性
    git命令行
    ue4 lightmass研究
    leecode保存 简单题到ZY转换
    ue4 skybox
    ue4导入staticMesh
    uml类图的几种关系
  • 原文地址:https://www.cnblogs.com/liuswi/p/2876177.html
Copyright © 2011-2022 走看看