Mif*_*Fox 22
Image myImage = Image.FromFile("myimage.png");
myImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/en-us/library/system.drawing.image.rotateflip.aspx
下面是一些示例代码(不是我写的-发现前一段时间在这里),对我的工作,只要你编辑的一些细节.
private Bitmap rotateImage(Bitmap b, float angle)
{
//create a new empty bitmap to hold rotated image
Bitmap returnBitmap = new Bitmap(b.Width, b.Height);
//make a graphics object from the empty bitmap
using (Graphics g = Graphics.FromImage(returnBitmap))
{
//move rotation point to center of image
g.TranslateTransform((float)b.Width / 2, (float)b.Height / 2);
//rotate
g.RotateTransform(angle);
//move image back
g.TranslateTransform(-(float)b.Width / 2, -(float)b.Height / 2);
//draw passed in image onto graphics object
g.DrawImage(b, new Point(0, 0));
}
return returnBitmap;
}
Run Code Online (Sandbox Code Playgroud)
请注意,这可能无法"开箱即用" - 新位图存在一些问题.旋转时,它可能不适合放在旧位图的矩形中(矩形边界b.Width,B.Height).
无论如何,这只是为了给你一个想法.如果您选择这样做,我相信您将能够计算出所有细节.我发布了我的最终代码,但是我现在还没有发布它...
| 归档时间: |
|
| 查看次数: |
10926 次 |
| 最近记录: |