2016-04-26 50 views

回答

0

我做了一些找你,發現這個:

public static 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; 
} 
+0

這可以工作,但也存在一些問題。首先,如果位圖圖像是矩形,則新的位圖圖像將截斷圖像。據推測,這可以通過使新位圖成爲最大邊的平方來解決。但是,即使這樣做後,我正在經歷削波。如果可以的話,我會張貼一張照片。 – zetar

+0

我以某種方式解決了這個問題。我只是把我的原始位圖圖像做成方形(帶有額外的空白)。 RotateImage代碼現在可以正常工作,並且我使用透明的白色將變換後的圖像進行blit處理。 – zetar