如题,类似Windows图片和传真查看其,这个小程序有放大、缩小、旋转等按钮。谢谢指教!

解决方案 »

  1.   

    javascript的实现:   
        
        
      <body>   
      <img   src="2.jpg"><br>   
      <input   type=button   value="放大"   onclick="large()">   
      <input   type=button   value="缩小"   onclick="small()">   
      <input   type=button   value="旋转"   onclick="rotate()">   
      <input   type=button   value="打印"   onclick="printPic()">   
      </body>   
      <script>   
      var   img=document.getElementsByTagName('img')[0];   
      function   small()   
      {   
          img.width=img.width*0.5;   
          img.height=img.height*0.5;   
      }   
      function   large()   
      {   
          img.width=img.width*2;   
          img.height=img.height*2;   
      }   
      function   rotate()   
      {   
          //rotation:   1   旋转90度   ;2   旋转180度     ;3   旋转270度   
          img.style.filter='progid:DXImageTransform.Microsoft.BasicImage(rotation=1)'   
      }   
      function   printPic()   
      {   
          window.print();   
      }   
      </script>
      

  2.   

    www.hotajax.org 上有现成的。
      

  3.   

       public Image RotateImg(Image b, int angle)
            {
                angle = angle % 360;
                double radian = angle * Math.PI ;
                double cos = Math.Cos(radian);
                double sin = Math.Sin(radian);
                int w = b.Width;
                int h = b.Height;
                int W = (int)(Math.Max(Math.Abs(w * cos - h * sin), Math.Abs(w * cos + h * sin)));
                int H = (int)(Math.Max(Math.Abs(w * sin - h * cos), Math.Abs(w * sin + h * cos)));
                Bitmap dsImage = new Bitmap(W, H);
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(dsImage);
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                Point Offset = new Point((W - w) / 2, (H - h) / 2);
                Rectangle rect = new Rectangle(Offset.X, Offset.Y, w, h);
                Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
                g.TranslateTransform(center.X, center.Y);
                g.RotateTransform(360 - angle);
                g.TranslateTransform(-center.X, -center.Y);
                g.DrawImage(b, rect);
                g.ResetTransform();
                g.Save();
                g.Dispose();
                b.Dispose();
                dsImage.Save("b.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                return dsImage;
            }
    放大缩小参考
    或用js实现