注册 登录
编程论坛 ASP技术论坛

按比例显示图片

favoriteran 发布于 2008-01-09 13:43, 1204 次点击
请头号asp中如何按比例显示图片,自动按比例缩放?
4 回复
#2
xmuer2008-01-09 22:42
【无限缩小放大图片代码】
<input type="button" value="缩小" onclick="small1()">
              <input type="button" value="放大" onclick="big1()">
              <br>
              <BR>
              <img border="0"  name=images1 src="图片.jpg">
          <script>
function small(){
var height1=images0.height
var width1=images0.width
images0.height=height1/1.5
images0.width=width1/1.5}

function big(){
var height1=images0.height
var width1=images0.width
images0.height=height1*1.5
images0.width=width1*1.5}

function small1(){
var height1=images1.height
var width1=images1.width
images1.height=height1/1.5
images1.width=width1/1.5}

function big1(){
var height1=images1.height
var width1=images1.width
images1.height=height1*1.5
images1.width=width1*1.5}
</script>
#3
madpbpl2008-01-10 00:46
前两个function有什么用?
#4
放任一切2008-01-12 16:47
图片成比例缩放
<script>   
  function   DrawImage(ImgD){   
        var   image=new   Image();   
        var   iwidth   =   120;     //定义允许图片宽度   
        var   iheight   =   90;     //定义允许图片高度   
        image.src=ImgD.src;   
        if(image.width>0   &&   image.height>0){   
          flag=true;   
          if(image.width/image.height>=   iwidth/iheight){   
            if(image.width>iwidth){      
            ImgD.width=iwidth;   
            ImgD.height=(image.height*iwidth)/image.width;   
            }else{   
            ImgD.width=image.width;      
            ImgD.height=image.height;   
            }   
            ImgD.alt=image.width+"×"+image.height;   
            }   
          else{   
            if(image.height>iheight){      
            ImgD.height=iheight;   
            ImgD.width=(image.width*iheight)/image.height;            
            }else{   
            ImgD.width=image.width;      
            ImgD.height=image.height;   
            }   
            ImgD.alt=image.width+"×"+image.height;   
            }   
          }   
  }     
   
  </script>   
   
   
   
   
  <html><body>   
  <img   src="http://img.blog.   

name="dd"   onload="DrawImage(this);">   
   
  </body>   
  </html>
#5
hangxj2008-01-12 18:00
学习一下
1