首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

使用GDI+绘图时候发生的文图,图像只画了一部份,请问一上大家

2013-02-02 
使用GDI+绘图时候发生的文图,图像只画了一部份,请教一下大家如上图所示,当我用GDI+使图片旋转的时候,发现

使用GDI+绘图时候发生的文图,图像只画了一部份,请教一下大家

如上图所示,当我用GDI+使图片旋转的时候,发现图片只显示了一部分,这是哪里出错了,想不出哪里出问题了,郁闷,下面是代码,请大家指教一下



   Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim ag As Graphics
        ag = Me.CreateGraphics
        Dim pbleft, pbtop As Single
        pbleft = 312 + 60
        pbtop = 169 + 60
        Dim rotatePoint As New PointF(pbleft, pbtop)
        Dim mymatrix As New Matrix
        mymatrix.RotateAt(-10, rotatePoint, MatrixOrder.Append)
        ag.Transform = mymatrix
        Dim newImage As Image = Image.FromFile("D:\66.png")
        Dim ulCorner As New PointF(312.0F, 169.0F)
        ag.DrawImage(newImage, ulCorner)
        ag.Dispose()

    End Sub



图片大小是120×120
[解决办法]
1.首先设置Graphics旋转中心为图形中心
2.旋转指定角度,单位(度)
3.绘图
4.回复Graphics旋转中心

                Graphics g = e.Graphics;
                g.TranslateTransform(pictureBox1.Width / 2, pictureBox1.Height / 2);
                g.RotateTransform(angle);
                g.DrawImage(boximg, -pictureBox1.Width / 2, -pictureBox1.Height / 2, pictureBox1.Width, pictureBox1.Height);
                g.RotateTransform(-angle);
                g.ResetTransform();

热点排行