Reputation: 11201
I'm testing my app in an iPhone5.
I duplicate an image, named image1.png and [email protected], and tried it in iPhone5, in some part of my code:
UIImage *myImage = [UIImage imageNamed:@"image1.png"] ;
CGFloat imageWidth = myImage.size.width;
CGFloat imageHeight = myImage.size.height;
NSLog(@"image %f %f", imageWidth,imageHeight);
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;
NSLog(@"screen %f %f", screenWidth, screenHeight);
and when running in the iphone, in the console I see:
2013-04-05 13:13:48.386 Vallabici[2413:907] image 320.000000 57.000000
2013-04-05 13:13:48.389 Vallabici[2413:907] screen 320.000000 568.000000
as it was using normal screen instead of retina.
how can it be?
Upvotes: 0
Views: 61
Reputation: 6176
screens are always measured in pixel
and retina pixels are always = non retina pixel
by code you'll get always screen pixel of 230x480 (on iPhones < 5)
the difference is how images are rendered: on retina display they are rendered at double resolution
It's like printer devices: you can print a small image to an A4 paper filling it, and then print a bigger image...
images printed to paper have always the same measures (in inches or centimeters), but the quality of the results change
Upvotes: 1
Reputation: 32066
bounds
returns the size of the screen in points, not pixels
See the documentation.
The same is true of size
Upvotes: 2
Reputation: 69499
The size of the image should not change on the retina device, just the scale. To take the scale of the image add the following log:
NSLog(@"scale %f", myImage.scale);
Upvotes: 2