2009-09-07 28 views

回答

0

下面的代码工作。 但我仍然无法找到我的查询的实际答案。

int compression = NSTIFFCompressionPackBits; 

CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)dataToWrite, NULL); 

CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); 

CFMutableDictionaryRef saveMetaAndOpts = CFDictionaryCreateMutable(nil,0,&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 

CFMutableDictionaryRef tiffProfsMut = CFDictionaryCreateMutable(nil, 0, 
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 

CFDictionarySetValue(tiffProfsMut, kCGImagePropertyTIFFCompression, CFNumberCreate(NULL, kCFNumberIntType, &compression)); 
CFDictionarySetValue(saveMetaAndOpts, kCGImagePropertyTIFFDictionary, tiffProfsMut); 

NSURL *outURL = [[NSURL alloc] initFileURLWithPath:filename]; 
CGImageDestinationRef dr = CGImageDestinationCreateWithURL ((CFURLRef)outURL, (CFStringRef)@"public.tiff" , 1, NULL); 
CGImageDestinationAddImage(dr, imageRef, saveMetaAndOpts); 
CGImageDestinationFinalize(dr); 

CFRelease(dr); 
[outURL release]; 
CFRelease(tiffProfsMut); 
CFRelease(saveMetaAndOpts); 
CFRelease(imageRef); 

CFRelease(source); 
3

代替

sips -s formatOptions packbits /DefaultGroup.tif 

尝试

sips -s formatOptions pacbits /DefaultGroup.tif 

换句话说,而不是使用 'PACKBITS' pacbits“。

有点令人惊讶,但它是。