0

ICO ファイルを保存して読みたいと思います。NSImage か NSBitmapImageRep か何かかどうかは関係ありません。それはただ行う必要があります。これはどのように達成できますか?

4

1 に答える 1

1

私は自分でそれを見つけました。これが私のコードです:

NSImage *o = [[NSImage alloc] initWithContentsOfFile:path];
CGImageDestinationRef dest = CGImageDestinationCreateWithURL(
                                                             (CFURLRef)[NSURL fileURLWithPath:newPath], 
                                                             (CFStringRef)@"com.microsoft.ico", 
                                                             o.representations.count,
                                                             NULL);
for (NSBitmapImageRep *rep in o.representations) {
    CGImageRef ref = rep.CGImage;
    CGImageDestinationAddImage(dest, 
                               ref, 
                               NULL);
}


CGImageDestinationFinalize(dest);
于 2010-07-11T03:17:41.053 に答える