On May 24, 2012, at 12:19 AM, Gustavo Adolfo Pizano wrote:

> For the transformation I'm using gesture recognizers.
> when I want to compose the image this is are the steps I'm doing
> 
> UIGraphicsBeginImageContext(size)  //size is a CGSize with 900x567
> CGContextRef ctx = UIGraphicsGetCurrentContext();
> CGContextSetAllowsAntialiasing(ctx, YES);
> CGContextSetShouldAntialias(ctx, YES);
> CGContextConcatCTM(ctx, _imageView.transform);

The image view's transform is going to be with respect to the center of the 
image view, but you are translating the context with respect to its origin. You 
need to translate to the center of the context before you apply this transform.

> [_imageView.image
> drawAtPoint:CGPointMake(-_image.size.width/2,-_image.size.height/2)];
> 
> UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
>  UIGraphicsEndImageContext();


As a general comment, you really shouldn't use your _imageView as a data model 
object (that is, as a container for the transform and image) as it 
unnecessarily locks you into using the UIImageView as the "truth". Consider for 
example if you wanted to use a placeholder image in your UI - you would need to 
somehow communicate the real image to this code via a UIImageView. Instead from 
an architecture POV you should should model this as an image and a transform, 
and the UIImageView and this code just happen to share these two components.
--
David Duncan


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to