WrightsCS
WrightsCS

Reputation: 50697

Erica Saduns iPhone Developers Cookbook (3.0) Chap 08, Exercise 14 — Resize and Rotate

Regarding Erica Sadun's iPhone Developer Cookbook, in Chapter 8, Exercise 14 Resize and Rotate: the example works just fine, I am able to rotate, resize and whatever. The issue is, how do you reference the altered image after it has been scaled, rotate? When attempting to save the photo, it is saved as the original photo and not the edited one.

Upvotes: 0

Views: 271

Answers (1)

aroth
aroth

Reputation: 54796

I assume you are resizing and rotating a UIImageView that is visible on the device's screen. If this is the case, then your manipulations are being applied as matrix transformations on the UIView when it renders, and are not actually modifying the backing image at all. So if you want to save a snapshot of the image's current state, then you need to draw your view into an appropriately-sized CGContext, and then create a new image from that context.

You may find these resources helpful:

How to render UIView into a CGContext

http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

Upvotes: 2

Related Questions