我在可可Mac应用程序中使用以下代码创建JPEG。如何将srgb颜色配置文件嵌入到创建的JPEG中?
NSImage* savedImage = [[NSImage alloc] initWithSize:NSMakeSize(600, 600)];
[savedImage lockFocus];
//draw here
[savedImage unlockFocus];
NSBitmapImageRep* savedImageBitmapRep = [NSBitmapImageRep imageRepWithData:[savedImage TIFFRepresentationUsingCompression:NSTIFFCompressionNone factor:1.0]];
NSDictionary* properties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:1.0], kCGImageDestinationLossyCompressionQuality,
nil];
NSMutableData* imageData = [NSMutableData data];
CGImageDestinationRef imageDest = CGImageDestinationCreateWithData((CFMutableDataRef) imageData, kUTTypeJPEG, 1, NULL);
CGImageDestinationAddImage(imageDest, [savedImageBitmapRep CGImage], (CFDictionaryRef) properties);
CGImageDestinationFinalize(imageDest);
// Do something with imageData
if (![imageData writeToFile:[@"~/Desktop/test.jpg" stringByExpandingTildeInPath] atomically:NO])
NSLog(@"Failed to write imageData");
最佳答案
不知道如何使用这些高级API来执行此操作。我自己通过将所需的IFD添加到JPEG数据中来完成此操作。
关于objective-c - 从 cocoa Mac App创建的JPEG中嵌入颜色配置文件sRGB,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9241737/