2009-09-07 5 views

Répondre

0

Le code ci-dessous fonctionne. Mais je n'ai toujours pas trouvé la réponse réelle à ma requête.

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

Au lieu de

sips -s formatOptions packbits /DefaultGroup.tif 

essayer

sips -s formatOptions pacbits /DefaultGroup.tif 

En d'autres termes, utiliser 'pacbits' au lieu de 'PackBits'.

Sorte de surprenant, mais il est là.

Questions connexes