我想保存并阅读ICO文件。它的NSImage或NSBitmapImageRep或其他任何东西都无关紧要。它只需要完成。怎么能实现呢?
答案 0 :(得分: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);