private Image rotateImage(Image b, double angle)
{
//create a new empty bitmap to hold rotated image
Bitmap returnBitmap = new Bitmap(2*b.Width, 2*b.Height);
//make a graphics object from the empty bitmap
Graphics g = Graphics.FromImage(returnBitmap);
//move rotation point to center of image
g.TranslateTransform(center_x, center_y);
//rotate
g.RotateTransform(-(float)(angle*180.0/Math.PI));
//move image back
g.TranslateTransform(-center_x, -center_y);
//draw passed in image onto graphics object
g.DrawImage(b, new Point(0, 0));
return returnBitmap;
}
A collection of my projects in the areas of physics, electronics and information science.
AdSense
Monday 20 May 2013
C# Windows Forms - Rotate image
(Deutsche Version) For Panzerkampf it is necessary to rotate an image. The solution which I use is:
Labels:
C#,
Panzerkampf,
Windows Forms
Subscribe to:
Post Comments (Atom)
Image rotation in C# with Rotator for Windows Forms
ReplyDelete