Monday, January 31, 2011

How to Prevent Retina Scaling

I have an app that will receive the correct image size based on what device is being used.  On the iPhone 4 with retina display, this causes a problem when I just use [UIImage imageWithData:imageData].  The image appears twice as large as it should.

The answer is fairly simple.  It involves using a lower level method to get the image:

UIImage *imageToReturn = [UIImage imageWithData:imageData];
    imageToReturn = [UIImage imageWithCGImage:imageToReturn.CGImage scale:2 orientation:imageToReturn.imageOrientation];

No comments:

Post a Comment