我试图LinearDNG在我的 MacOS 应用程序中打开文件。据我调查,这是不可能的CoreImage。
所以,问题:
LinearDNG是否可以使用16 位/8 位 RGBA 数据打开文件CoreImage?LinearDNG是否可以使用16 位/8 位 RGBA 数据打开文件dcraw?- 您知道将
LinearDNG文件作为 16 位/8 位 RGBA 数据打开的其他库吗?
我的 LinearDNG 文件是 16 位的。相关EXIF数据:
File Type : DNG
File Type Extension : dng
MIME Type : image/x-adobe-dng
Bits Per Sample : 16 16 16
Compression : Uncompressed
Photometric Interpretation : Linear Raw
Format : image/jpeg
我读过CIContext可以将图像转换为TIFF/JPEG,但是带有此特定LinearDNG文件的代码不起作用。所有 JPEG 图像都是黑色的,所有 TIFF 图像都是透明的。我想CIImage只是不理解这种编码。
我的测试代码:
[self convertLinearDNGToJPEG:@"super_jpeg.jpeg"];
[self convertLinearDNGToTIFF:kCIFormatRGBA8 fileName:@"super_kCIFormatRGBA8.tiff"];
[self convertLinearDNGToTIFF:kCIFormatRGBA16 fileName:@"super_kCIFormatRGBA16.tiff"];
[self convertLinearDNGToTIFF:kCIFormatARGB8 fileName:@"super_kCIFormatARGB8.tiff"];
[self convertLinearDNGToTIFF:kCIFormatRGBAh fileName:@"super_kCIFormatRGBAh.tiff"];
对应的函数(convertLinearDNGToTIFF/ convertLinearDNGToJPEG ):
- (void)convertLinearDNGToJPEG:(NSString*)fileName
{
CIImage* inputImage = [self createInputImage];
NSError* superError = nil;
CIContext* ciContext = [self createCiContext];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSURL* superURL = [NSURL fileURLWithPath: [documentsDirectory stringByAppendingPathComponent:fileName] ];
CGColorSpaceRef superColorSpace = CGColorSpaceCreateDeviceRGB();
[ciContext writeJPEGRepresentationOfImage:inputImage
toURL:superURL
colorSpace:superColorSpace
options:@{} // CIImageRepresentationOption
error:&superError];
}
- (void)convertLinearDNGToTIFF:(CIFormat)format fileName:(NSString*)fileName
{
CIImage* inputImage = [self createInputImage];
NSError* superError = nil;
CIContext* ciContext = [self createCiContext];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSURL* superURL = [NSURL fileURLWithPath: [documentsDirectory stringByAppendingPathComponent:fileName] ];
CGColorSpaceRef superColorSpace = CGColorSpaceCreateDeviceRGB();
[ciContext writeTIFFRepresentationOfImage:inputImage
toURL:superURL
format:format
colorSpace:superColorSpace
options:@{} // CIImageRepresentationOption
error:&superError];
}