retina-display

How to save PNG file from NSImage (retina issues)

戏子无情 提交于 2019-11-27 00:45:56
I'm doing some operations on images and after I'm done, I want to save the image as PNG on disk. I'm doing the following: + (void)saveImage:(NSImage *)image atPath:(NSString *)path { [image lockFocus] ; NSBitmapImageRep *imageRepresentation = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0.0, 0.0, image.size.width, image.size.height)] ; [image unlockFocus] ; NSData *data = [imageRepresentation representationUsingType:NSPNGFileType properties:nil]; [data writeToFile:path atomically:YES]; } This code is working, but the problem is with retina mac, if I print the NSBitmapImageRep

Serving high res images to retina display

萝らか妹 提交于 2019-11-27 00:39:30
问题 how to detect, in a cross-browser compatible way , the pixel density of the device visiting a webpage so that one can either serve standard or highres images without forcing doubled images to any device? Is there any javascript library that automates this? 回答1: Why setting for Retina iPhone 4s, iPhone 5, iPad3, iPad4, Macbook 15", Macbook 13" all use Retina display. Android also support high resolution display, as well as Windows 8(Lumia 920) as mentioned by @JamWaffles. Adding high

What is the best way to detect retina support on a device using JavaScript?

你离开我真会死。 提交于 2019-11-27 00:21:53
Right now I am using this: function is_retina_device() { return window.devicePixelRatio > 1; } But it's simplicity scares me. Is there is a more thorough check? According to everything that I've read recently, browsers seem to be moving towards the resolution media query expression. This is instead of device-pixel-ratio that is being used in the currently accepted answer. The reason why device-pixel-ratio should only be used as a fallback is because it is not a standard media query. According to w3.org: Once upon a time, Webkit decided a media query for the screen resolution was needed. But

Images for retina screen (@2x)

大城市里の小女人 提交于 2019-11-26 23:47:13
问题 Now I am making a Game with spritekit(swift) in Xcode 6. It has to be playable for iPhone 4s and higher. But as far as I know are all iphones from 4s and higher Retina so I can add all images with (750 x 1334 pix) and with @2x.png. So I do not need to add images without @2x.. Am I correct? 回答1: Example: If you have a 512 x 512 (1x) image and you want it to support (2x and 3x) you have to include those 2 files like this: yourImage.png // (512x512 at 1x) yourImage@2x.png // (1024x1024 at 2x)

How to simulate a retina display (HiDPI mode) in Mac OS X 10.8 Mountain Lion on a non-retina display?

别等时光非礼了梦想. 提交于 2019-11-26 23:25:55
How can you simulate a retina display (HiDPI mode) in Mac OS X 10.8 Mountain Lion on a non-retina display? Dave Gallagher Search for , download, and install Apple's free Additional Tools for Xcode 8 (for previous Xcode releases search for Graphics Tools for Xcode according to your version). Note: free Apple Developer account required. Launch Quartz Debug application. Go to menu: Window ---> UI Resolution . Check Enable HiDPI display modes . Quit Quartz Debug . Open System Preferences . Select Displays icon. If using multiple display, select the configuration window on the display you wish to

detect retina (HD) display on the server side

混江龙づ霸主 提交于 2019-11-26 23:14:20
问题 I found many questions about Retina Display, but none of the answers were on the server side. I would like to deliver a different image according to the screen, ex (in PHP): if( $is_retina) $thumbnail = get_image( $item_photo, 'thumbnail_retina' ) ; else $thumbnail = get_image( $item_photo, 'thumbnail' ) ; Can you see a way of dealing with this? I can only imagine a test in JavaScript, setting a Cookie. However this requires an initial exchange to set it. Anyone have a better solution? Cookie

Saving UIView contents in iOS 4 with real size of the images inside (i.e. scale contentes up for save)

回眸只為那壹抹淺笑 提交于 2019-11-26 22:44:36
问题 I have an UIView with many UIImageViews as subviews. The app runs on iOS4 and I use images with retina display resolution (i.e. the images load with scale = 2) I want to save the contents of the UIView ... BUT ... have the real size of the images inside. I.e. the view has size 200x200 and images with scale=2 inside, I'd like to save a resulting image of 400x400 and all the images with their real size. Now what comes first to mind is to create a new image context and load again all images

LESS CSS set variables in media query?

我与影子孤独终老i 提交于 2019-11-26 22:24:45
问题 I'm working on a iPad-specific website. To make my website work on both the retina display iPad and older versions of iPads, I want to set a variable in LESS CSS in media query like: @media all and (max-width: 768px) { @ratio: 1; } @media all and (min-width: 769px) { @ratio: 2; } So when you are setting anything in pixels, you can do width: 100px * @ratio; But I got a compile error saying @ratio is not defined. Is it possible to have a workaround to make it work? Thanks. 回答1: It would be nice

How to programmatically get iOS status bar height

和自甴很熟 提交于 2019-11-26 18:43:03
问题 I know that currently the status bar (with the time, battery, and network connection) at the top of the iPhone/iPad is 20 pixels for non-retina screens and 40 pixels for retina screens, but to future proof my app I would like to be able to determine this without hard coding values. Is it possible to figure out the height of the status bar programmatically? 回答1: [UIApplication sharedApplication].statusBarFrame.size.height . But since all sizes are in points, not in pixels, status bar height

iPhone 5 - what naming convention the new images have to follow?

独自空忆成欢 提交于 2019-11-26 15:31:52
问题 What name convention the new images have to have to be loaded by the new iPhone 5? We see that we have to have 3 default images to be loaded by the device Default.png Default@2x.png and Default-568h@2x.png what about the other images used by an app? Is there a naming convention that will automatically load the correct image? 回答1: The new default is Default-568h@2x.png. (note hyphen) There is no other corresponding change. If you need a different image for the new iPhone 5 screen then you have