0

我尝试在没有 alpha 通道的情况下保存 NSBItmapImageRep。我的代码是:

NSBitmapImageRep* rep = [[NSBitmapImageRep alloc] initWithCIImage:img];
NSColorSpace *targetColorSpace = [NSColorSpace genericGrayColorSpace];
NSBitmapImageRep *targetImageRep = [rep bitmapImageRepByConvertingToColorSpace:targetColorSpace 
                                                               renderingIntent:NSColorRenderingIntentPerceptual];

NSData* PNGData = [targetImageRep representationUsingType:NSPNGFileType properties:nil];
[PNGData writeToURL:url atomically:YES];    
[rep release];

但它不起作用。它使用 GrayScaleAlpha 类型保存我的图像。如何指定使用 alpha?

4

0 回答 0