简体   繁体   English

10.7.4和libPNG

[英]10.7.4 and libPNG

Ever since I updated to 10.7.4 I started having issues with my NSImage code. 自从我更新到10.7.4版以来,我的NSImage代码开始出现问题。 When I read out the representations of an image, select the Bitmap image representation and try to write it out to a PNG file I receive an error. 当我读出图像的表示形式时,请选择“位图”图像表示形式,然后尝试将其写出到PNG文件中,但会收到错误消息。

Therefore I tried doing it through the 'regular' way, with the following errors: 因此,我尝试通过“常规”方式进行操作,但出现以下错误:

在此处输入图片说明

My first guess would be removing the broken version of libPNG and replacing it with a working one. 我的第一个猜测是删除损坏的libPNG版本,并用一个可用的版本替换它。 Any suggestions on how I should tackle this problem? 关于如何解决这个问题有什么建议吗? I could try compiling an old version of libPNG and read out the bitmap image and write it out myself. 我可以尝试编译旧版本的libPNG并读出位图图像,然后自己写出来。 Love it how the quality of OSX degraded to the level of windows vista in Lion. 非常喜欢OSX的质量如何降低到Lion中的Windows Vista水平。

And yes, OSX uses libPNG: http://d.pr/i/nOEX 是的,OSX使用libPNG: http ://d.pr/i/nOEX

To clarify it a bit more, here is my test build code: 为了更清楚一点,这是我的测试构建代码:

NSImage *image = [[NSImage alloc] initWithContentsOfFile:@"/Users/jabwd/Desktop/Icons/4099.ico"];

    NSLog(@"%@",[image representations]);
    NSImageRep *biggest = nil;
    for(NSImageRep *rep in [image representations])
    {
        if( ! biggest )
        {
            biggest = rep;
        }
        else if( [rep size].width >= [biggest size].width && [rep size].height >= [biggest size].height )
        {
            biggest = rep;
        }
    }

    if( biggest && [biggest isKindOfClass:[NSBitmapImageRep class]] )
    {
        NSBitmapImageRep *bitmap = (NSBitmapImageRep *)biggest;
        NSData *data = [bitmap representationUsingType:NSPNGFileType properties:nil];
        [data writeToFile:@"/Users/jabwd/Desktop/test.png" atomically:false];
    }

As you can see I assume there are multiple representations in the image. 如您所见,我假设图像中有多种表示形式。 I can do this in this case because there is a certain type of icons I'm loading, its a private project and won't get into the hands of some users => there is a certain task for another bigger application I have which needs to be automated. 我可以在这种情况下执行此操作,因为我正在加载某种类型的图标,这是一个私人项目,不会被某些用户使用=>对于我拥有的另一个更大的应用程序,它有一项特定的任务自动化。

Looks like ImageIO.framework has a few bugs in 10.7.4, its the same libPNG version found on 10.7.3. 看起来ImageIO.framework在10.7.4中有一些错误,与在10.7.3中找到的libPNG版本相同。 Using an automator script to convert the images to jpegs before converting them to pngs seems to be working. 在将图像转换为png之前,使用自动脚本将图像转换为jpeg似乎可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM