★搜Asp.net★(www.soAsp.net),为专业技术文档网站。
包括Asp.net开发技术文档·C#开发技术文档·Access/SQL Server数据库开发技术文档·VB.NET开发技术文档。
还包括·项目实战经验总结·开发经验技巧总结·项目开发心得。


  
C#实现任意角度旋转图片

以任意角度旋转图像示例。

实现任意角度旋转图像主要使用Graphics类提供的RotateTransform()方法。代码如下:

private void button1_Click(object sender, EventArgs e)
{
    //以任意角度旋转显示图像
    Graphics g = this.panel1.CreateGraphics();
    float MyAngle = 0;//旋转的角度
    while (MyAngle < 360)
    {
        TextureBrush MyBrush = new TextureBrush(MyBitmap);
        this.panel1.Refresh();
        MyBrush.RotateTransform(MyAngle);
        g.FillRectangle(MyBrush, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);
        MyAngle += 0.5f;
        System.Threading.Thread.Sleep(50);
    }
}