我試圖旋轉用C#的照片,和我使用此代碼的圖片:旋轉畫面切
///create a new empty bitmap to hold rotated image
Bitmap returnBitmap = new Bitmap(newBMP.Width, newBMP.Height);
//make a graphics object from the empty bitmap
Graphics g = Graphics.FromImage(returnBitmap);
//move rotation point to center of image
g.TranslateTransform((float)newBMP.Width/2, (float)newBMP.Height/2);
//rotate
g.RotateTransform(-90);
//move image back
g.TranslateTransform(-(float)newBMP.Width/2, -(float)newBMP.Height/2);
//draw passed in image onto graphics object
g.DrawImage(newBMP, new Point(0, 0));
的newBMP
是我從一個形式得到一個位圖,我改變了尺寸。然後我想旋轉它,但是當我嘗試上面的代碼時,它會切割圖片的頂部和底部。 完成這一切後,我將新圖片保存在服務器上。
一切工作正常,除了旋轉...
任何人看到這個問題?
解決我用這個:C# rotate bitmap 90 degrees
肯定的寬度和高度或如果旋轉90°,需要交換「returnBitmap」? – 2013-03-13 14:40:11
我同意以前的評論。您可以將寬度和高度更改爲90°,180°。任何度在這裏看到我的解決方案:[stackoverflow.com:C#,旋轉圖形?](https://stackoverflow.com/questions/5172906/c-rotating-graphics/48725273#48725273) – 2018-02-10 20:38:32