calculate new image size before CGContextRotateCTM
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 befor开发者_运维知识库e I start the rotation?
Thank you very much in advance.
For anyone passing by: This post answers my problem:
Calculate Bounding box coordinates from a rotated rectangle, Picture inside
Thanks, m
精彩评论