Convert CATransform3D to CIVector for CIPerspectiveTransform, replace UIGetScreenImage

Is it possible to convert a CATransform3D to a set of CIVectors to convert a UIImage with a CATransform3D ?

I believe that it is now possible to replace the ability of UIGetScreenImage() smooth 3D UIView/CALayer with an image, going through the hierarchy of representations and rendering of individual images, and then applying CATransform3D to the image that was created,

I started working with GPUImage , which takes CATransform3Ds to apply to UIImage and, unfortunately, no luck. Attached code that I used and links to created images.

Simulator screenshot

Image produced

 - (UIImage*)iterateLayerHierarchy:(CALayer*)layer { UIGraphicsBeginImageContextWithOptions(CGSizeMake(layer.frame.size.width, layer.frame.size.height), NO, 0.0); for (CALayer *sublayer in layer.sublayers) { UIImage* subImage; if (sublayer.sublayers.count > 1) { subImage = [self iterateLayerHierarchy:sublayer]; } else { subImage = [UIView getImageFromLayer:sublayer]; } CGRect imageRect; if (isRetina()) { imageRect = CGRectMake(sublayer.position.x-subImage.size.width/4, sublayer.position.y-subImage.size.height/4, subImage.size.width, subImage.size.height); }else{ imageRect = CGRectMake(sublayer.position.x-subImage.size.width/2, sublayer.position.y-subImage.size.height/2, subImage.size.width, subImage.size.height); } [subImage drawInRect:imageRect]; //sublayer.hidden = YES; } UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } + (UIImage*) getImageFromLayer:(CALayer *)layer { UIGraphicsBeginImageContextWithOptions(CGSizeMake(layer.bounds.size.width, layer.bounds.size.height), NO, 0.0); [layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); if (!CATransform3DEqualToTransform(layer.transform, CATransform3DIdentity)) { GPUImageTransformFilter *transformFilter = [[GPUImageTransformFilter alloc] init]; transformFilter.transform3D = layer.transform; img = [transformFilter imageByFilteringImage:img]; } return img; } 
+4
source share
1 answer

Not being a direct answer to the question, with iOS 7 you no longer need to solve this problem. "UIGetScreenImage ()" has been effectively replaced by "drawViewHierarchyInRect:", which is capable of capturing both OpenGL layers and UIKit-based views at the same time.

0
source

All Articles