質問

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.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top