zoukankan      html  css  js  c++  java
  • 前端

            //图片大小控制ImgD图片路径,ImgW是宽或高
            function DrawImage(ImgD,ImgW){
                var image=new Image();
                image.src=ImgD.src;
    
                if(image.width>0 && image.height>0){
    
                    if(image.width/image.height>= 1){
                        if(image.width>ImgW){
                            ImgD.width=ImgW;
                            ImgD.height=(image.height*ImgW)/image.width;
                        }else{
                            ImgD.width=image.width;
                            ImgD.height=image.height;
                        }
                        ImgD.alt=image.width+"×"+image.height;
                    }
                    else{
                        if(image.height>ImgW){
                            ImgD.height=ImgW;
                            ImgD.width=(image.width*ImgW)/image.height;
                        }else{
    //ImgD.width=(image.width*ImgW)/image.height;
                            ImgD.width=image.width;
                            ImgD.height=image.height;
                        }
                        ImgD.alt=image.width+"×"+image.height;
                    }
                }
           
                console.log(ImgD); // 里面有图片的信息,拿出来用
    
            }
  • 相关阅读:
    test14
    test13
    test12
    test11
    Xcode常用快捷键
    OC弱语法
    对象的结构体属性的成员修改
    IOS 获取手机各种信息
    IOS app启动过程
    iOS退出键盘的两种方式
  • 原文地址:https://www.cnblogs.com/pyspang/p/11900318.html
Copyright © 2011-2022 走看看