How to save PNG file from NSImage (retina issues)
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