小编wet*_*eve的帖子

如何从NSImage保存PNG文件(视网膜问题)正确的方法?

我试图将数组中的每个图像保存为.PNG文件(也是正确的大小,因为视网膜mac dpi问题没有按比例放大)并且似乎无法找到解决方案.如何从NSImage(视网膜问题)保存PNG文件的解决方案似乎没有为我工作.我已经尝试了每一个,他们每个人仍然会在视网膜.etc中将72x72文件保存为144x144.

更具体地说,我正在寻找一个NSImage类别(是的,我在Mac环境中工作)

我试图让用户选择一个目录来保存它们并执行从数组中保存图像,如下所示:

- (IBAction)saveImages:(id)sender {
    // Prepare Images that are checked and put them in an array
    [self prepareImages];

    if ([preparedImages count] == 0) {
        NSLog(@"We have no preparedImages to save!");
        NSAlert *alert = [[NSAlert alloc] init];
        [alert setAlertStyle:NSInformationalAlertStyle];
        [alert setMessageText:NSLocalizedString(@"Error", @"Save Images Error Text")];
        [alert setInformativeText:NSLocalizedString(@"You have not selected any images to create.", @"Save Images Error Informative Text")];

        [alert beginSheetModalForWindow:self.window
                          modalDelegate:self
                        didEndSelector:@selector(testDatabaseConnectionDidEnd:returnCode:
                                                   contextInfo:)
                            contextInfo:nil];
        return;
    } else {
        NSLog(@"We have prepared %lu images.", (unsigned long)[preparedImages …
Run Code Online (Sandbox Code Playgroud)

macos xcode png save retina

5
推荐指数
2
解决办法
2663
查看次数

标签 统计

macos ×1

png ×1

retina ×1

save ×1

xcode ×1