Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloading normal image Vs retina device image (2x)

When we need to download an image from some URL and show it on two kinds of devices -- Retina (with 2x image) and regular device -- Should we have two different image URLs to handle this?

For the images in the resource bundle we are keeping both xyz.png and [email protected] and its working fine.

For images we are fetching from server do we need to have separate image URLs for both these kind of images and cache them locally with the same naming convention (xyz.png and [email protected])?

Please throw some light here.

like image 838
Abhinav Avatar asked Apr 01 '11 20:04

Abhinav


People also ask

What is 2x retina?

To accommodate high resolution/retina displays, you'll want to use an image that's 1280 pixels wide, which is what's referred to as “2x”. While the graphic will still display on the website at 640 pixels wide, you are doubling the pixel density by using an image that's double the size.

What is Retina ready images?

Retina-ready websites are websites that utilise modern technology to display high-resolution images on devices that have high definition (HD) displays, such as the many tablets and smartphones, and some modern laptops, macbooks and desktop PCs.

How do I make an image retina ready?

To make your website retina-ready, use Scalable Vector Graphics (SVG) whenever possible. SVG is an XML-based graphic format that presents images in high quality. SVG images can be viewed in Internet browsers that use XML or be displayed on mobile phones in SVGB or SVGT file formats.

What is retina image in WordPress?

WordPress retina images The term "retina images" is thrown around a lot, but basically it means they are high resolution. High resolution images are also used in the PC world on 4k monitors, Windows 10 laptops, and tablets.


1 Answers

You can check if the device has a high-resolution retina display and based on that download a different image. Don't bother for photos and stuff that you'd scale anyway for interface size.
You can create the scaled version of the downloaded image with

UIImage *image = //download...
image=[UIImage imageWithCGImage:[image CGImage] scale:2.0 orientation:UIImageOrientationUp];

Keep in mind that a scaled 100x100 image will become a 50x50 points image (with 2.0 scale).

Check first if you have a retina display

BOOL retina = NO;
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
    retina = [[UIScreen mainScreen] scale] == 2.0 ? YES : NO;
like image 51
unexpectedvalue Avatar answered Oct 24 '22 17:10

unexpectedvalue