Guest User

Untitled

a guest
Jun 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. Matrix myPathMatrix;
  2. myPathMatrix.Translate(x, y, MatrixOrderAppend);
  3. myPathMatrix.Rotate(angle, MatrixOrderAppend);
  4. canvas->SetTransform(&myPathMatrix);
  5. Draw(canvas);// draw the image
  6. myPathMatrix.Rotate(-angle, MatrixOrderAppend);
  7. myPathMatrix.Translate(-x, -y, MatrixOrderAppend);
  8. canvas->SetTransform(&myPathMatrix);
  9.  
  10. private Bitmap rotateImage(Bitmap b, float angle)
  11. {
  12. //create a new empty bitmap to hold rotated image
  13. Bitmap returnBitmap = new Bitmap(b.Width, b.Height);
  14. //make a graphics object from the empty bitmap
  15. Graphics g = Graphics.FromImage(returnBitmap);
  16. //move rotation point to center of image
  17. g.TranslateTransform((float)b.Width/2, (float)b.Height / 2);
  18. //rotate
  19. g.RotateTransform(angle);
  20. //move image back
  21. g.TranslateTransform(-(float)b.Width/2,-(float)b.Height / 2);
  22. //draw passed in image onto graphics object
  23. g.DrawImage(b, new Point(0, 0));
  24. return returnBitmap;
  25. }
Add Comment
Please, Sign In to add comment