Open GoogleCodeExporter opened 9 years ago
- (void) updateMirroredScreenOnDisplayLink
{
// Get a screenshot of the main window
//CGImageRef mainWindowScreenshot = UIGetScreenImage();
UIWindow *theScreen = [[UIApplication sharedApplication].windows objectAtIndex:0];
UIGraphicsBeginImageContext(theScreen.frame.size);
[[theScreen layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mainWindowScreenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if (mainWindowScreenshot) {
// Copy to secondary screen
mirroredScreenWindow.layer.contents = (id)mainWindowScreenshot.CGImage;
// Clean up as UIGetScreenImage does NOT respect retain / release semantics
//CFRelease(mainWindowScreenshot);
}
}
Original comment by erik.mad...@gmail.com
on 17 Aug 2010 at 7:58
This doesn't seem to work for me... Does it for anyone else...?
Original comment by jvanv...@gmail.com
on 10 Sep 2010 at 6:28
- (void) updateMirroredScreenOnDisplayLink
{
// from http://developer.apple.com/iphone/library/qa/qa2010/qa1703.html
// bonus, this works in the simulator; sadly, it doesn't capture the status bar
//
// if you are making an OpenGL app, use UIGetScreenImage() above or switch the
// following code to match Apple's sample at http://developer.apple.com/iphone/library/qa/qa2010/qa1704.html
// note that you'll need to pass in a reference to your eaglview to get that to work.
UIGraphicsBeginImageContext([[UIApplication sharedApplication] keyWindow].bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// get every window's contents (i.e. so you can see alerts, ads, etc.)
for (UIWindow *window in [[UIApplication sharedApplication] windows])
{
if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen])
{
CGContextSaveGState(context);
CGContextTranslateCTM(context, [window center].x, [window center].y);
CGContextConcatCTM(context, [window transform]);
CGContextTranslateCTM(context, -[window bounds].size.width * window.layer.anchorPoint.x, -[window bounds].size.height * window.layer.anchorPoint.y);
[[window layer] renderInContext:context];
CGContextRestoreGState(context);
}
}
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
CGImageRef mainWindowScreenshot = [image CGImage];
UIGraphicsEndImageContext();
if (mainWindowScreenshot) {
// Copy to secondary screen
mirroredScreenWindow.layer.contents = (id) mainWindowScreenshot;
}
}
Original comment by dkf2...@gmail.com
on 10 Sep 2010 at 9:30
This isn't working for me - I'm just getting a blank screen on my TV Out. Any
suggestions?
Original comment by ash.furrow
on 25 Nov 2010 at 3:07
It's working for me, except a small video replay gets shown using the
UIGetScreenImage method but not using the screenshot method.
Original comment by christin...@gmail.com
on 16 Dec 2010 at 4:15
Original issue reported on code.google.com by
maurois...@gmail.com
on 15 Aug 2010 at 10:42