开发者

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

开发者 https://www.devze.com 2023-04-01 10:31 出处:网络
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 whatev开发者_开发百科er. The issue is, how

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 whatev开发者_开发百科er. 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.


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消