Normal background image is 320x480 pixels. and for retina is 640x960 pixels.
Now i have to put my background image and i have status bar(20) and navigation bar (44).
So i have to reduce 64(20+44) from 480(normal) or from 960(retina)?
if i reduce 64 from normal then normal image will be 320x416 pixels and retina will be 640x832 pixels.
if i reduce 64 from retina then normal will be 320x448 and retina will be 640x896 .
It is confusing me.. this 64(20+44) i reduce from which image type because other one will be exactly half or double of it.
Reduce from the normal size.
64px = height to remove from normal display.
128px = height to remove from the retina.
Don't forget that in the retina display the status bar and nav bar will also be 2x the height :)
You do everything based upon the 320x480 size, then retina scales everything up. Using images suffixed #2x will allow you to replace the assets (mainly UIImage) for the retina version, this doesnt work for direct resource file references or video/audio files though so just be careful.
So measure for 320 for all your assets then your retina ones will simply be twice the size
Related
I know that 2x images are for retina display.
But i want to know that how can we identify that my device is using 1x image or 2x image?
and one more thing
I have one image name stackOverflow.png of size 50x50 and its 2x with name stackOverflow#2x.png of size 100x98.
My question is that device will select retina image with name or size???
To check which one has been loaded, you can use this code:
UIImage *image = [UIImage imageNamed:#"image"];
NSLog(#"scale: %f", image.scale); //this will be 2.0 for retina image
Or just simply use two different images, as #MidhunMP suggested in comments.
It's usually not hard to tell just by looking at them-- especially in the iOS simulator. Set the simulator to retina mode and take a look. Non-retina images will be visibly blurry compared to retina images.
As for the image size, if your 2x image is not actually 2x the size of the original image, you are doing it wrong. Fix one image or the other, or both. Retina images are selected by name. If the size is wrong, the image will be stretched to fit. That will ruin the high-resolution retina effect you're trying to get with a 2x image.
I am using Default.png for iPhone and Default-Landscape.png for ipad. But in case of ipad the splash screen shows only half of the image and rest is cut. It seems to be the size of image becomes double of what it should be. I am using image with width:525 and height:175 for ipad.
I also added:
UILaunchImageFile~ipad Default-Landscape.png
in my info.plist file. What might be the problem? Please guide me....
Also can i set the backgroung of splash screen to white????
The landscape iPad launch image has to be 1024x748 pixels. That's the only size that will prevent your image from scaling.
I guess the iPad tries to scale your image to a height of 748 which means the width will be 2244px. Not exactly double but something like four times the size of what you want.
Create a white image with dimensions of 1024x748 and put your 525x175 image in the middle of it.
Try the image name Default#2x.png and size would be 1024X768....
I have a UIImage, from either device's camera or downloaded from a URL. Say resolution is 800x600.
I want to display a scaled image in a UIImageView which is 200x150, and I have a proper image scaling code.
So, I just scale the UIImage to the UIImageView's frame.size (again, 200x150). On a non-retina display it looks OK, but on a retina display it looks bad, like a smaller picture was scaled up, because the actual frame in pixels is 400x300.
The question is - should I, manually multiply the frame.size.width/height by 2 when it's a retina display when I resize, so it'll be resized to 400x300, or is there a built in feature for that?
Since the UIImage is not a resource on the device, I don't have the #2x option.
Keep the frame size of the image view at 200x150 in all cases.
In case of non-retina display scale the image to 200x150. On retina display devices scale it to 400x300. Set the contentMode of the UIImageView to UIViewContentModeScaleAspectFit.
When you get the image in say 800x600, can't you make a UIImage that is scaled to 400x300 and save it temporarily with the #2x extension, maybe to the Documents folder or tmp folder, and then save another UIImage scaled to 200x150 and save it without the #2x in the same directory.
I am showing a high resolution image in iphone 4 and i set the image view frame size as below :
imageFrameNormal.size.width = 470;
imageFrameNormal.size.height = 625;
but it showing full screen instead of this size. so plz can any one suggest how i show image in right size.
i am trying to check it in simulator.
Thx
You have to use the same sizes on retina and normal displays. For example, you have image view with size 100x100. On retina device you should use the same size 100x100 (no changes in your code). However you'd better use high-res image (2x size). For this you need to name it properly:
image.png - normal size image
image#2x.png - 2x size image.
When you call
UIImage* img = [UIImage imageNamed: #"image.png"];
image.png would be used on normal display and image#2x.png on retina (iOS does it automatically).
The retina display's coordinate system is not in pixels, but in "points". The iPhone display, whether retina or legacy will always be 320x480 points. When interacting with any parameters such as the frame, size, origin, etc., you will need to remember to use points instead of pixels. The OS will handle the "conversion" between points and pixels for you.
For a much more detailed explanation, see Points vs. Pixels in the Drawing and Printing Guide for iOS.
I am having a problem in iphone 4. The images used in iPhone less than 4 are fine but when I upgraded to iphone 4 the images looks distorted.
Here is the link.
The image size I have used is 320 x 480.
http://img822.imageshack.us/img822/8431/download22.png
Thanks.
The fact is that the resolution of iPhone4 is 960x640 instead that 480x320 so the image is scaled with linear (or bilinear, not sure) filtering.. the result is what you get: a blurry image.
Just redo the image with the proper resolution to solve the problem, you mainly notice these kinds of artifacts because you have rasterized text on an image..
You obtain this effect whenever you resize an image to fit a wider area of pixels: the missing pixels must be filled somehow and filtering comes into play. So you will have to consider also that part of the screen is used by the top bar to have an exact sized picture.
Create a #2x suffix to each of your png that you use.
example:
Icon.png
Icon#2x.png
The runtime environment will choose the double-resolution on retina display devices.
It looks like your original image is 480x320, but you aren't accounting for the fact that the status bar is compressing your image slightly (or perhaps it does on the iPhone4 but on the older iPhones it is cropping instead).
I'd check the image view settings for that background image.