0
我有一個NSImage,我想保存爲PNG,但刪除Alpha通道並使用5位顏色。我目前這樣做是爲了創建我的PNG:保存NSImage爲無alpha和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嗎?任何幫助,與代碼片段將不勝感激。
乾杯
戴夫