How to rotate monochrome images in GDI+
I am trying to rotate a monochrome Bitmap in GDI+ using RotateFlip method. When i try to rotate it by 90/270 I get a wrong image or the application crashes. But when I try to rotate it by 180 degrees it works fine. Hence I am now rotating all开发者_Go百科 monochrome bitmaps twice through 180 and then rotating it again by the angle required.
Is this a known bug in GDI+? Any other good workarounds would be appreciated.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Matrix m = new Matrix();
Bitmap bmp = new Bitmap("myfile");
m.Rotate(30);
e.Graphics.Transform = m;
e.Graphics.DrawImageUnscaled(bmp);
Looks like a known bug in GDI+: connect.microsoft.com/.../image-rotateflip-works-incorrectly-with-certain-images
精彩评论