How to save a NSImage as a new file
原文连接:http://stackoverflow.com/questions/3038820/how-to-save-a-nsimage-as-a-new-file
How can I save a NSImage as a new file (png, jpg, ...) in a certain directory?
Thank you for answering my "noobish" question.
NSBitmapImageRep *imgRep = [[image representations] objectAtIndex: 0];
NSData *data = [imgRep representationUsingType: NSPNGFileType properties: nil];
[data writeToFile: @"/path/to/file.png" atomically: NO];
本文介绍了一种将 NSImage 对象保存为指定目录下的 PNG 或 JPG 文件的方法。通过使用 NSBitmapImageRep 类来获取图像的表示形式,并利用 NSData 将其转换为文件格式,最后写入到指定路径。
815

被折叠的 条评论
为什么被折叠?



