I’m writing a video app and need the ability to capture the Corona view asynchronously (my captureScreen + display.save method was extremely inefficient.)
PROBLEM: Instead of capturing the Corona context, this code exports solid black jpgs at 750 x 1334.
id\<CoronaRuntime\> runtime = (id\<CoronaRuntime\>)CoronaLuaGetContext( L ); CGRect rect = [runtime.appViewController.view bounds]; UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f); CGContextRef context = UIGraphicsGetCurrentContext(); [runtime.appViewController.view.layer renderInContext:context]; UIImage \*capturedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSString \*tmpDirectory = NSTemporaryDirectory(); NSString \*exportUrl = [tmpDirectory stringByAppendingPathComponent:"frame.jpg"]; [UIImageJPEGRepresentation(capturedImage, 1.0) writeToFile:exportUrl atomically:NO];
Any help is greatly appreciated.
Best,
Aidan