在C#中使用RotateFlip旋转图像 [英] Rotate Image using RotateFlip in C#
本文介绍了在C#中使用RotateFlip旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码可以在C#Windows Form应用程序的if循环中旋转图像,但是Form在表单输出中不显示任何内容.
I have this code to rotate an image in an if loop in C# Windows Form application, but the Form does not show anything in the form output.
任何人都可以帮忙吗?
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方法.请查看我的示例代码:
if you need to rotate an image on common angles you can use RotateFlip method with ease. Please see my sample code:
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();
仅此而已,希望对您有所帮助.
That's all, hope it helps.
这篇关于在C#中使用RotateFlip旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文