2

I have an iOS app which allows the user to apply a series of 3D transforms before taking a screenshot which can be emailed or saved to the camera roll. This works great on screen, but the transforms get lost in the process of creating the image.

For example, when using the following transform:

double degrees = 10;
double radians = (degrees / 180) * M_PI;

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -100;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, radians, 0.0f, 1.0f, 0.0f);

...it looks like this on the device: 3D Transform on screen

However, the resulting screenshot looks like this:

Screenshot taken from device

Note: I am taking the screenshot using the method recommended by Apple: http://developer.apple.com/library/ios/#qa/qa1703/_index.html#//apple_ref/doc/uid/DTS40010193

It doesn't look like UIGetScreenImage is an option given that it's a 'hidden' API, meaning that the app will probably get rejected.

Any suggestions would be much appreciated. If you're interested in taking a look then I have created a simple XCode project on Bitbucket: https://bitbucket.org/ian_tipton/3d-rotate-to-image

Ian
  • 7,480
  • 2
  • 47
  • 51
  • This is effectively the same question as is asked here: http://stackoverflow.com/questions/1949003/how-do-i-create-a-uiimage-from-a-3d-transformed-uiimageview-layer , because -renderInContext: drops the 3-D portion of CATransform3D transformations on views. – Brad Larson May 16 '13 at 19:17
  • Load the UIImage into a UIWebView (via HTML injection) and then transform the image there (via CSS3 or Javascript injection) and then user `renderInContext` on your UIWebView. – Albert Renshaw Jul 29 '13 at 21:16
  • (*Side note, you can set a UIWebView's background to transparent with CSS (and by ALSO toggling the background settings in objective-c) so that your 3D transformed image isn't enclosed by an opaque blank white square) – Albert Renshaw Jul 29 '13 at 21:18

0 Answers0