Search code examples
iosretina-displayipad-3

Screenshot Using UIGraphicsBeginImageContextWithOptions For iPad 3 (Retina)


I am taking a screenshot using the following code:

    // Returns 1024x768 for iPad Retina
    CGSize screenDimensions = [[UIScreen mainScreen] bounds].size;

    // Create a graphics context with the target size
    // (last parameter takes scale into account)
    UIGraphicsBeginImageContextWithOptions(screenDimensions, NO, 0);

    // Render the view to a new context
    CGContextRef context = UIGraphicsGetCurrentContext();
    [myView.layer renderInContext:context];

    // Save to Camera Roll
    UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
    UIImageWriteToSavedPhotosAlbum(screenshot, self, nil, nil);

    UIGraphicsEndImageContext();

This works, however I have a report from a user that this results in an image in the Camera Roll that is not at the iPad retina resolution. Rather it looks more like the iPad non-retina resolution. (I don't have an iPad 3 to test this on).

Is there anything else that I am doing wrong?


Solution

  • So I finally got a hold of a physical iPad Retina, and the code that I posted originally works fine. The resulting image does appear to be at the full Retina resolution.