• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Transforming UIImage (rotate, translate, scale) and then crop to constant size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Transforming UIImage (rotate, translate, scale) and then crop to constant size


  • Subject: Transforming UIImage (rotate, translate, scale) and then crop to constant size
  • From: Gustavo Adolfo Pizano <email@hidden>
  • Date: Thu, 24 May 2012 09:19:44 +0200

Hello all.

I have an app which the user can transform an image (rotate,
translate, scale), On top of this image is an image has, so mostly the
user fits in the mask the portion of the image that he wants.

Then I need to compose an image based on what is inside the mask.
Problem is that the composed image must have 900wX567h px, the mast is
1/3 of those dimensions.

So this is what i do.

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);

[_imageView.image
drawAtPoint:CGPointMake(-_image.size.width/2,-_image.size.height/2)];

 UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();


So I get an image, with the right size, but what is in the image is
completely different of what was inside the mask when the user edited.

I have tried scaling the context and translating it, but nothing. I
have close results but mostly the position and scale are wrong.

I would appreciate any help you can provide me in this matter, as I
dunno what I'm missing...

Thanks in advance

Gustavo
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Transforming UIImage (rotate, translate, scale) and then crop to constant size
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: NSMutableData capacity
  • Next by Date: Re: NSMutableData capacity
  • Previous by thread: Re: Debugging uiscrollview not responding to user
  • Next by thread: Re: Transforming UIImage (rotate, translate, scale) and then crop to constant size
  • Index(es):
    • Date
    • Thread