Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why capturing the view if you have the original image? Just apply the transformations to it. Something like this may be a start:</p> <pre><code>UIImage *image = [UIImage imageNamed:@"&lt;# original #&gt;"]; CIImage *cimage = [CIImage imageWithCGImage:image.CGImage]; // build the transform you want CGAffineTransform t = CGAffineTransformIdentity; CGFloat angle = [(NSNumber *)[self.faceImageView valueForKeyPath:@"layer.transform.rotation.z"] floatValue]; CGFloat scale = [(NSNumber *)[self.faceImageView valueForKeyPath:@"layer.transform.scale"] floatValue]; t = CGAffineTransformConcat(t, CGAffineTransformMakeScale(scale, scale)); t = CGAffineTransformConcat(t, CGAffineTransformMakeRotation(-angle)); // create a new CIImage using the transform, crop, filters, etc. CIImage *timage = [cimage imageByApplyingTransform:t]; // draw the result CIContext *context = [CIContext contextWithOptions:nil]; CGImageRef imageRef = [context createCGImage:timage fromRect:[timage extent]]; UIImage *result = [UIImage imageWithCGImage:imageRef]; // save to disk NSData *png = UIImagePNGRepresentation(result); NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/result.png"]; if (png &amp;&amp; [png writeToFile:path atomically:NO]) { NSLog(@"\n%@", path); } CGImageRelease(imageRef); </code></pre> <p>You can easily crop the output if that's what you want (see <code>-[CIImage imageByCroppingToRect]</code> or take into account the translation, apply a Core Image filter, etc. depending on what are your exact needs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload