PNG として保存したい NSImage がありますが、アルファ チャネルを削除して 5 ビット カラーを使用します。現在、PNGを作成するためにこれを行っています:
NSData *imageData = [image TIFFRepresentation];
NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:imageData];
NSDictionary *imageProps = nil;
imageData = [imageRep representationUsingType:NSPNGFileType properties:imageProps];
[imageData writeToFile:fileNameWithExtension atomically:YES];
SOに関する同様の質問をたくさん読んだことがありますが、使用するための最良/正しいアプローチについて混乱しています。新しい CGGraphics コンテキストを作成し、そこに描画しますか? これらのパラメーターを使用して新しい imageRep を直接作成できますか? コードスニペットを使用して、どんな助けでも大歓迎です。
乾杯
デイブ