1

Greetings!

This question is rather mathematical, with the iphone SDK/quartz as example:

I am rotating an image using CGContextRotateCTM:

  • Create a new context with the size of the source image
  • rotate source image and draw it in context
  • pass context to new rotated image.

This works fine, but the image is cut off at the edges, because it doesn't fit into the source image size. I would like to resize the context/the resulting image so that the entire rotated image is visible.

What algorithm could I use to calculate the needed size of the context before I start the rotation?

Thank you very much in advance.

marimba
  • 3,116
  • 5
  • 26
  • 29

1 Answers1

0

For anyone passing by: This post answers my problem:

Calculate Bounding box coordinates from a rotated rectangle, Picture inside

Thanks, m

Community
  • 1
  • 1
marimba
  • 3,116
  • 5
  • 26
  • 29