Xcode does not recognize change in size of image - iphone

In my program I have an image which has been scaled down to a size which fits perfectly on the screen. Upon further investigation, I realized those dimensions must be doubled to provide maximum quality in iPhone Retina. I doubled those dimensions by using the original image (which was much larger) so there was no loss in quality. However, when I run my program in iPhone simulator (retina display) the image's quality has not changed whatsoever. Is there any apparent reason why Xcode does not seem to recognize that the image has been updated? Any help is appreciated.

When you have two versions of the image (normal and #2x), use the "normal" name (without #2x) in XIB or UIImage#imageWithName:, system will automatically choose the best version for the current screen. Also check that your UIImageView size corresponds to the normal (not 2x) resolution of your image. There are several content modes (like Aspect Fit, Aspect Fill, Center, etc.) that will resize or position your image in the UIImageView.

Related

How to handle resolution change 320x480 => 640x960 related to gameplay

I have decided to have 2 set of images for my iPod game. One with 320x480 and the other for the retina one. I can switch happily between them but this forces me to add extra code to handle the change in resolution.
My game is played in screen space on a grid, so, if I have 32 pixel tiles, I will have to use 32 offsets in low res and 64 in retina (because of doubling resolution). For a simple game this can be no problem, but what about other more complex games? How do you handle this without hardcoding things depending on the target resolution.
Of course an easy way to bypass this is just releasing a 320x480 version an let the hardware upscale, but this is not what I want because of blurry images. I'm a bit lost here.
If you have to, you can do the conversion from points to pixels (and vice versa), easily by either multiplying or dividing the pixel/point position with the contentScaleFactor of your view. However, normally this is done automatically by you if you just keep it to using points instead of pixels.
This is automatic. You only need to add image files suffixed '#2x' for the retina resolution.
Regarding pixels, from your program you work in points which are translated to pixels by the system. Screen dimensions are 320x480 points for iphone retina and non-retina.

how to maintain image resolution after doing zooming?

after doing zooming i am loosing image resolution.
How to maintained the resolution of an image. even the image is zoom - in.
#thanks in adavance.
I try my level best no luck.
Is core graphics will help me out. or CATiledLayer will help me out with this kind of the issue.
You could use a large initial image, which is scaled down by the app at run time. If your screen is 768 x 1024, then the image placed in the zoomable view might be 1536 x 2048. This way it maintains detail even as you zoom.
If you need an even larger image, there are some 3rd party libraries on GitHub that support dividing up larger images and placing them in a scroll view.

use photoshop to change image resolution for iphone4 vs iphone3

I have a psd which is for iphone4 640x960. Inside photoshop, the image size says the resolution is 72pixels/inch. How do I decrease the resolution by half for the iphone3's 320x480? I tried changing 72 to 36, but that didn't do anything.
This isn't really a programming question, but the DPI is just a parameter on bitmapped images, given that they don't otherwise have any concept of physical size. You can set it to anything without affecting the actual pixels.
You want to adjust 'Image Size', which when I last used Photoshop (a very long time ago) was under the 'Image' menu. You then want to set the size in pixels to 320x480.

iPhone image resource - 1024 maximum, 2048 pixels #2x?

The restriction of 1024x1024 as the largest image for an iPhone is a problem with iPhone 4. However if an #2x image is used with maximum dimensions of 2048x2048 everything looks equally good on the 4 as it does on a 3 - tried and tested in simulator and device. Question is, does the image dimension restriction relate to the UIImage or the resource that it contains? I can't imagine resources of more than 1024 pixels are discouraged with the 960 pixel height of the screen.
The right answer is really to use tiles so that things look even better, but the deadline for for this deliverable is too close - it's a future thing.
From UIImage class reference:
You should avoid creating UIImage
objects that are greater than 1024 x
1024 in size. Besides the large amount
of memory such an image would consume,
you may run into problems when using
the image as a texture in OpenGL ES or
when drawing the image to a view or
layer. This size restriction does not
apply if you are performing code-based
manipulations, such as resizing an
image larger than 1024 x 1024 pixels
by drawing it to a bitmap-backed
graphics context. In fact, you may
need to resize an image in this manner
(or break it into several smaller
images) in order to draw it to one of
your views.
That is, views are rendered and composited with the iPhone's GPU. If your view, for example, overrides drawRect and tries to render a very big UIImage you might run into problems. Newer generation iDevices, such as iPad and iPhone 4 support bigger textures than 1024x1024 (2048x2048 I think).
I didn't realise there was a restriction, I'm using an image 15198 × 252 as the scrolling landscape in Scramble... works really well, though I must say I did have reservations before I tried it out!

Easy way of exporting #2x images for retina display?

I am creating a lot of webviews that must be compatible with both the iPhone 4 retina display and pre-iPhone 4 devices. It's painstaking to export multiple files for each image.
Is there a script or utility to automate this process?
If you're using Photoshop to process your artwork you just need to record an action while resizing an image to 50% of its original width and height. Using the image processor (Files > Scripts > Image Processor) you can then run the action on all images stored in a folder you specify. The images will be stored to a new location, so renaming them is easy.
Keep in mind however that resizing images (even if the new resolution is smaller than the old one) may render sharp and graphic content blurry sometimes. If your artwork is mostly graphical in nature and has been created in Adobe Illustrator (or a similar application) you should export the different resolutions right there.
Also keep in mind that the larger resolution images should be easy to resize to half the original width and height - you should be able do divide both values by two.
Imagine an image of 13 x 13 pixels (at #2x resolution), which will be scaled down to 6 x 6 or 7 x 7 pixels. You design your interface using the smaller size. For displaying the high resolution image, the iPhone will double the smaller images bounds, which would result in 12 x 12 or 14 x 14 pixels. The #2x image wouldn't fit precisely anymore - so there's either clipping, glitches at the edges or the image is slightly blurred because it needs to be stretched or pinched to fit in.
Finally, if you don't use Photoshop, here's two freeware tools that allow batch resizing of images too:
Fotosizer
Irfanview