Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Matrix myPathMatrix;
- myPathMatrix.Translate(x, y, MatrixOrderAppend);
- myPathMatrix.Rotate(angle, MatrixOrderAppend);
- canvas->SetTransform(&myPathMatrix);
- Draw(canvas);// draw the image
- myPathMatrix.Rotate(-angle, MatrixOrderAppend);
- myPathMatrix.Translate(-x, -y, MatrixOrderAppend);
- canvas->SetTransform(&myPathMatrix);
- 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
- 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;
- }
Add Comment
Please, Sign In to add comment