大致是这样的:用Image控件获取了数据库中的图片,图片在数据库中为具体路径,如:http://192.168.0.42/pic/1.jpg。在Page_Load中读取如:this.Image1.ImageUrl = vPath //vPath为路径。怎么样让该图片放大或缩小,鼠标滚动或点击<放大>、<缩小>也可!求代码,谢谢啦!

解决方案 »

  1.   

    等比例缩放图片
    <script language="JavaScript">
    var flag=false;
    function DrawImage(ImgD,iwidth,iheight){
      var image=new Image();
      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;
      }  }
    }  
    image.GetThumbnailImage
      

  2.   

    我的图片是在后台获得的,
    for (int i = 0; i < dt.Rows.Count; i++)
            {
                //string vCode = dt.Rows[i]["code"].ToString();
                //Response.Write(vCode);
                string path = dt.Rows[i]["path"].ToString();
                string vPath = path.Replace(";", "");
                this.Image1.ImageUrl = vPath + "\r";
                        }而且是“http://192.168.0.42/pic/1.jpg”这样的形式。我想知道在后台怎么做!
      

  3.   

    这个跟后台不后台没有关系
    2楼的JS就可以了,自己根据需要改改,因为放大缩小在客户端通过JS来操作就可以了
      

  4.   

    <img src="http://……" border="1" onmousewheel="return bigImage(this)"/>
    那么src怎么获得后台从数据库读取的路径。
      

  5.   

    后台定义一个picsrc,将数据库读到的值赋给它,绑定在前台。。
    <img src="<%=picsrc%>" border="1" onmousewheel="return bigImage(this)"/>