views:

190

answers:

1

I display an image in a UIImageView (within a UIScrollView) which is also stored in CoreData.

In the interface, I want the user to be able to rotate the picture by 90 degrees. I also want it to be saved in CoreData.

What should I rotate in the display? the scrollview, the uiimageview or the image itself? (If possible I would like the rotation to be animated) But then I also have to save the picture to CoreData.

I thought about changing the image orientation but this property is readonly.

+1  A: 

To just display the image rotated, you should rotate the UIImageView.

You could store some metadata along with the image in CoreData saying what rotation should be applied.

Some image formats have an implicit rotation property. If you know the compressed image data format you can look up the specification and see if it supports it.

If you are going to actually rotate the image pixels, you will have to do that manually. You can create a CGBitmapContext and draw the image into it rotated by messing with the transform matrix, then create a new image from the bitmap.

drawnonward
I actually store the images as JPEG and I think it supports orientation. But can I access that from Cocoa?
Kamchatka