Understanding Image Size for Different Resolution Screens - ios

I'm having a hard time putting all the information on image sizes for #1x, #2x, and #3x together. I've been using the scene editor in XCode with the scene size being 1334x750 (pixel dimensions of the screen of the iPhone 6). So when I size an image for a sprite in that scene, is that the size I should use for the #2x?
From what I've read in the documentation CGSize uses points, not pixels, so if I have an image that is CGSize(width: 50, height: 50), is this independent of my scene size in the scene editor?
Bottom line question: How does the CGSize dimensions translate to how I export my images for #1x, #2x, and #3x in pixels and what should the PPI be when I export?

Xcode can handle vector images, so you can forget about #2X and #3X images if you are able to export your images as PDF e.g. in Sketches export panel one of the options for export format is PDF, so create your artwork #1X and export as PDF, then in Xcode when you add the image to Assets.xcassets, you can set the images Scales attribute to Single Scale. Xcode will generate the required #2X and #3X images from your vector PDF at build time.

The concept is simple. The size in Storyboard or Interface Builder should be the size of you asset in #1x format.
The retina display ( or the iPhone 6+ #3x size ) does not mean than you have much space than before, it means that you can draw 2 ( or 3 ) pixels where you draw 1 before.
So for a 50x50 px Image View, cou should have 3 assets :
- Image#1x.png ( 50x50 px)
- Image#2x.png ( 100x100 px)
- Image#3x.png ( 150x150 px)

Suppose you have created an image in your assets library consisting of 3 sets of same image, #1x.png having size 50x50 pixels, #2x.png of size 100x100 pixels and #3x.png size 150x150 pixels.
you don't needs to worry about which one to use in your storyboard(because storyboard automatically using #1x.png), and which one to use for the targeted device like as iPhone6, or iphone7, or iPad(because by default programing all hardware finds out their pixels relative required image among those #1x.png, #2x.png and #3x.png)
for further instructions you needs to study Auto layout Programing Guide
you can also view their apple's tutorial videos regarding Auto layout.
mysteries of auto layout part1
mysteries of auto layout part2

#1x and #2x used to relate to the retina graphics change when iPhone 4 came out.
iPhone 3GS was 320x480, iPhone 4 was 640x960. This meant that the points per inch were literally the same, but the ppi was doubled, hence the #2x. When the iPhone 5 came out, the only thing that changed was the height, so the ppi was the same for the width, no problems here.
Then we hit the 6 and 6+. At this point, apple said screw it, try to keep ppi that correlate to previous iPhones without having keep the previous iphones usable area, or provide bigger screen pixels for bigger devices. Now #2x has lost its original meaning
But, to really throw us off, they made the iPhone SE, which went back to the ppi screen size of the iPhone 5, so #2x makes sense again.
Basically, when thinking of the #2x graphics, think about the 1st iPhone resolution size.
Now, you have a choice to make. You can give your apps more/less usable area, you can black box the extra usable area, or you can scale and take some kind of quality loss due to game pixels not being 1:1 with the screen pixels anymore.

Related

Image sizes for iPhone are incorrect-

I have this image called image.png - I have created it in the 3 differen't sizes.
image#3x.png - 1001x132px
image#2x.png - 668x88px
image.png - 334x44px
What I dont understand is how come the #2x is 668px in width, when the iPhone 5&5S are only 640px wide?
I have designed the #3x using iPhone 6+ screen size.
Could someone please explain?
Let me explain you the difference between the iPhone screens, so you will understand the need of these #?x suffixes.
The first iPhone, and the two after it (3G and 3GS) had the standard display with dimensions w:320, h:480. With the introducing of iPhone 4, Apple also introduced the so called Retina display, which "packs" 4 physical pixels in 1 logical pixel (also called "point"), i.e.:
Now, even though the pixel dimensions of the iPhone 4 are w:640, h:960 (and iPhone 5/5C/5S w:640, h:1136), you still have screen size of w:320, h:480 points (respectively w:320, h:568 for 5/5C/5S). But because the coordinate system of the display uses points instead of pixels, the dimensions and position in points of all UI elements remains the same for every device.
What about the prefixes?
Now, the ratio between point and pixels is called "scale". UIScreen, UIView, UIImage, and CALayer classes have a property called scale, and when you load image with prefix #2x, the scale will be 2.0 and the display will fit 2x2 bitmap pixels from the image in one point. iPhone 6+ uses the #3x suffix because of the Retina HD display, which has scaling factor 3 and the image is afterwards downscaled from rendered 2208 × 1242 pixels to 1920 × 1080 pixels (points on the screen).
The downscaling ratio is 1920 / 2208 = 1080 / 1242 = 20 / 23. That
means every 23 pixels from the original render have to be mapped to 20
physical pixels. In other words the image is scaled down to
approximately 87% of its original size.
(source).
Required image sizes
For example if you want to have an image of green circle in a black square with dimensions w:100, h:100, you will need two more images: one with dimensions w:200, h:200 and one with w:300, h:300, as the system will scale them according to the suffix.
Where to go next
Here is some stuff to read (if I didn't explain it right or easy to understand). My advice: check the link above and the official Apple documentation for further knowledge:
Apple documentation: Supporting high-res devices
Apple documentation: Points vs. Pixels
#2x is using for retina display, like iphone 4, 4s, 5, 5s, 6, ipads ....
The image has 668px in width, I think it use for a view that could have extra area for view, like horizontal scroll view, tutorial pages, or for ipad ... ... or something like that ..
And yes, you're right about the width of retina display, it is just 640px.
Hope this may help.

Supporting #3x, #2x Tab bar icons with PaintCode 2 StyleKit

I followed the PaintCode tutorials on StyleKit and I've successfully exported icons into a Swift project (code only - MyStyleKit.swift file). I'm trying to understand the relationship between the UIImage generated in code and the image sizes expected for different iOS devices.
I wired up the MyStyleKit object in the storyboards to the image for the Tab bar icon. Works great but I can't tell if the resolution of the image is adjusting depending on the device. Apple's HIG suggests the tab bar icon size in pixels should be
75 x 75 px for #3x images (iphone6+)
50 x 50 px for #2x retina image
25 x 25 px for non-retina
Firstly what canvas size should I be choosing in PaintCode initially? I guessed at putting the canvas size as 25 x 25, reasoning that I should map to the UI points size.
When I rig up the icon in Storyboards does it automatically adjust to whether it needs #3x, #2x or #1x?
Should I be setting the canvas size to the UI points size?
Any help would be greatly appreciated.
Yes, set the canvas size to 25×25 points. You can then preview the canvas at #1x, #2x or #3x (or infinite) scale.
When you ask the StyleKit for image of this canvas, the returned UIImage will have the size of 25×25 points, but scale of the current screen. That means 25×25, 50×50 or 75×75 pixels.

What image sizes/retina sizes are necessary for iOS8 scaled app?

I'm building an app that designers only gave me one canvas size for (9x16 aspect ratio at 1242x2208). I started an app that doesn't fully leverage the iPhone 6+'s screen space. Instead, all devices will use the same layout and assets. I did this by removing the #3x launch screen image. The goal is to use the same point system for all devices (320x568 - including for iPhone 4S - the 320x568 will be in a scroll view to fit all the content since the app is designed for 9x16 aspect and the 4S is not).
With that said, for simplicity of the question, lets say I have a full screen image (320x568 points). What are the 3 necessary pixel resolutions I need for 1x, 2x, and 3x?
When I use an app like Prepo that takes a 3x image and scales it down to 2x and 1x automatically for me, this is what happens:
I add a 3x asset at 1242x2208. It spits out:
#2x with px dimensions of 828x1472
#1x with px dimensions of 414x736
That doesn't seem right to me, but then again the whole iOS retina resolutions thing confuses me quite a bit. Shouldn't the 1x resolution end up being 320x568?
It may be that you are mentally confusing apples with oranges. Let's say you have an app that is to run on both iPhone 4s and iPhone 6 Plus (the extremes). Then you have two concerns:
Resolution. The 4s screen has 2 pixels per point, while the 6 Plus screen has 3 pixels per point. Images must come in a 3x size for the 6 Plus and a 2x size for the 4s in order to look good on both screens. This is something that the Asset Catalog will help you with.
Layout. The two screens have different sizes and different proportions. Things will need to grow and shrink in order to fit nicely and look good on both. This is something that Auto Layout (constraints) will help you with.
The two things are both involved where images are to be displayed on the screen, but in two different ways. You will have different resolution images, and they will be displayed in differently sized UIImageViews that adjust the image's display size.

How to cut iOS8 assets from a PSD designed at 1242px by 2208px

The designers on a project I am responsible for developing (one of my first iOS projects) designed the app using a Photoshop canvas set at 1242x2208 pixels, which is the number of pixels that the iPhone 6+ uses. I've scoured the internet and am just getting more and more confused by all the conversions for 1x, 2x, 3x and to further the confusion, apple downsizes to 1080x1920.
Anyways, how do I cut the assets correctly for #1x, #2x, #3x? When I crop the element I want, I save it out at 3x. But what do I divide by to get the 2x and 1x versions?
Here's secondary question and a hypothetical situation: There is a button that is designed to be the full width of the screen in portrait, so the designer made it 1242x100. If I save it out at 3x, then scale it down for 2 and 1x, will this button fit all the different screen sizes all the way down to iPhone 4/4s, which has a smaller pixel dimension and different aspect ratio?
Confused, any help appreciated!
Example:
If you original artwork is 960px by 1704px, just save you image including "#3x"
image#3x.png // (960 x 1704)
Then you have to resize it to 640x1136 and save including "2x"
image#2x.png // (640x1136)
And then you have to resize it to 320x568 and save as 1x
image.png // (320x568)
Indeed the Retina sizes are confusing, but this is what auto resize is used for in Xcode.
But The API which Apple give us, chooses the #3, #2 and 1 sizes by itself. There isn't anything that the developer/designer needs to do but provide all three images. An example is:
ObjC:
+ (NSImage *)imageNamed:(NSString *)name]
Swift:
init?(named name: String) -> NSImage
Would just use the name of the image without the # etc... So, myImageName#3x.png myImageName#2x.png myImageName.png would just be referred to as "myImageName"
The API handles the rest :)
I have had the same problem. What I did was, after cutting all images for iPhone 6+(#3x), I just resized the PSD to iPhone 5's width which is 640px, (height would be 1138 px if you keep aspect ratio) and cut #2x images. For the 1x images, again resized to 320px width.
Just, iPhone 6+, iPhone 6 and iPhone 5 have almost same aspect ratio.
Good Luck!

Confused regarding #3x artwork for iPhone 6+

I have an app in the App store to which I want to add #3x files. I read various posts but I am not sure how to proceed.
I read that coordinate space for the iPhone 6 plus is 414x736 points, (X3) that yields 1242x2208 pixels and not 1080x1920. Also I read that the iPhone 6+ will divide that by 1.15 before rendering to the display which will make it fit.
So lets say my App has a button image that is 44x44 pixels (the #2x file), then I should draw it as 44/2*3*1.15 to make it fit my 1242x2208 photoshop canvas. (/2 for points, times 3 for pixels *1.15 to overscale)
Now Apple documentation says #3x button need to have 66 pixels area, so that seems too small as it is not scaled up by 1.15.
This leads me to think my App canvas should be 1080x1920 which would avoid the iPhone having expensive rescale. So which is right? of course #3x would not be #3x.
Forget the 1.15 thing or actual screen resolution. Just scale up your '#2x' assets by a factor of 3/2, and name them '#3x'. The rest will be taken care of by iOS.
Check these links - how #3x image is works with 1080x1920 size..
http://aten.co/2014/09/12/designing-from-iphone-5-to-iphone-6-iphone-6-more-than-i-bargained-for/
You have to set images in image asset, so iOS automatically assign 2x & 3x images.. for different devices.

Resources