我想保存和读取一个 ICO 文件。它的 NSImage 或 NSBitmapImageRep 或任何东西都没有关系。它只是需要完成。这怎么可能实现?
问问题
743 次
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 回答