문제

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