在C#中使用rotateflip旋转图像

我有这个代码在C#windows窗体应用程序中的if循环中旋转图像,但表单在表单输出中没有显示任何内容,任何人都可以帮忙吗?

this.splitContainer1.Panel2.Controls.Add(PictureBox1); PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; PictureBox1.Image = bitmap;// Image.FromFile(@"C:\image.jpg"); PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; PictureBox1.Image = (Image)(RotateImg(bitmap, 30.0f, Color.Transparent)); 

如果需要在常用角度上旋转图像,可以轻松使用RotateFlip方法。 请参阅我的示例代码:

 string fileName = "somefile.png"; System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Png; Bitmap bitmap =(Bitmap)Bitmap.FromFile(fileName ); //this will rotate image to the left... bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone); //lets save result back to file... bitmap.Save(fileName, imageFormat); bitmap.Dispose(); 

这就是全部,希望它有所帮助。

请试试这个:

PictureBox1.Images.RotateFlip(RotateFlipType.Rotate180FlipX); PictureBox1.Refresh();