为什么我用以下的代码,旋转后图片变小了?  
旋转九十度后,图片显示不全          
double fangle = (angle * Math.PI) / 180;
            int rwidth = System.Convert.ToInt32(_canvas.Height * Math.Sin(fangle) + _canvas.Width * Math.Cos(fangle));
            int rheight = System.Convert.ToInt32(_canvas.Width * Math.Sin(fangle) + _canvas.Height * Math.Cos(fangle));
            Bitmap bmp = new Bitmap(rwidth, rheight);
            Graphics pic = Graphics.FromImage(bmp);
            pic.TranslateTransform(rwidth / 2F, 0);
            pic.RotateTransform(angle, MatrixOrder.Prepend);
            pic.DrawImage(_canvas, new Rectangle(1, 1, _canvas.Width, _canvas.Height), new Rectangle(1, 1, rheight, rheight), GraphicsUnit.Pixel);

解决方案 »

  1.   

    那你用pic.DrewString 试验一下
      

  2.   

    int width = image.Width;
    int height = image.Height;
    #region
    if(type==0)
    {
    for(int i=0;i<width/2;i++)
    {
    for(int j=0;j<height;j++)
    {
    if(i!=width-1-i)
    {
    Color color = image.GetPixel(i,j);
    image.SetPixel(i,j,image.GetPixel(width-1-i,j));
    image.SetPixel(width-1-i,j,color);
    }
    }
    }
    }
    else if(type==1)
    {
    for(int i=0;i<width;i++)
    {
    for(int j=0;j<height/2;j++)
    {
    if(j!=height-1-j)
    {
    Color color = image.GetPixel(i,j);
    image.SetPixel(i,j,image.GetPixel(i,height-1-j));
    image.SetPixel(i,height-1-j,color);
    }
    }
    }
    }
    else if(type==2)
    {
    for(int i=0;i<width;i++)
    {
    for(int j=0;j<height/2;j++)
    {
    Color color = image.GetPixel(i,j);
    image.SetPixel(i,j,image.GetPixel(width-1-i,height-1-j));
    image.SetPixel(width-1-i,height-1-j,color);
    }
    }任意翻转
      

  3.   


    Dim bmp As New Bitmap(Me.PictureBox1.Image.Width, Me.PictureBox1.Image.Height)
    Dim g As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)
    Dim m As New Drawing2D.Matrix
    Dim m1 As New Drawing2D.Matrix
    Dim m2 As New Drawing2D.Matrix(1, 0, 0, -1, 0, bmp.Height) '*** 反射并平移
    m1.Multiply(m2)
    g.Transform = m1
    g.DrawImage(Me.PictureBox1.Image, 0, 0)
    Me.PictureBox2.Image = bmp
      

  4.   

    可能是你计算精度问题,从float=>int转换数值要变小。
    如果只是旋转90度,为什么还要用到PI和三角函数??长和高对调一下就好了。还有,你那个angle也不要去算吧,直接输入90.0F
      

  5.   

    this.pictureBox1.SizeMode=System.Windows.Forms.PictureBoxSizeMode.StretchImage;
    this.pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
    this.pictureBox1.Refresh();
      

  6.   

    this.pictureBox1.SizeMode=System.Windows.Forms.PictureBoxSizeMode.StretchImage;
    this.pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
    int i=this.pictureBox1.Height;
    this.pictureBox1.Height=this.pictureBox1.Width;
    this.pictureBox1.Width=i;
    this.pictureBox1.Refresh();