Frage

I have a question about the image output of a cocoa app. For the following code will create different sized images(2x or 1x depending on the display) in retina displays and non retina displays. But I want the output image is 225x300 in every situations.

NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
[image setScalesWhenResized:YES];
[image setSize:NSMakeSize(225, 300)];
[[image TIFFRepresentation]writeToURL:exportFileURL options:NSDataWritingAtomic error:&error];

My question is how to handle this correctly.

War es hilfreich?

Lösung

Since you are writing the image from an NSView according to your comment, you'll need to properly support hi resolution retina displays. If the view is displayed on a retina display, you may want to adjust for scaling. See Apples Documentation on this. You will have to convertFrom/ToBacking accordingly.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top