Archive

Archive for the ‘Uncategorized’ Category

MKMapView UIGraphicsGetImageFromCurrentImageContext not working on retina display

August 19, 2011 Comments off

Trying to capture image of a MKMapview was working on the iOS simulator, my iPod Touch and iPad, but not on my iPhone 4.

Turns out you have to use UIGraphicsBeginImageContextWithOptions…

This doesn’t work on the retina display:
(void)captureThumbnail:(id)theViewToCapture
{
UIGraphicsBeginImageContext(((UIView*)theViewToCapture).frame.size);
[((UIView*)theViewToCapture).layer renderInContext:UIGraphicsGetCurrentContext()];
theImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}

This does work on the retina display:
(void)captureThumbnail:(id)theViewToCapture
{
UIGraphicsBeginImageContextWithOptions(((UIView*)theViewToCapture).frame.size, NO, 0.0);
[((UIView*)theViewToCapture).layer renderInContext:UIGraphicsGetCurrentContext()];
theImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}

Categories: Uncategorized Tags: , ,
Follow

Get every new post delivered to your Inbox.