Photoshop は私をかなり混乱させています。
Photoshop からマルチレイヤー tif イメージを作成し、それを自分のプログラム (ココア ビルド) に読み込むことができます。
プログラムでマルチレイヤー tif を作成し、tiffutil で読み取ることができます。
ただし、Photoshop は私のファイルをマルチレイヤー tif として認識しません。最初の画像だけが入ります。
どのような情報を含める必要がありますか? そして、どうすればそれを行うことができますか?tif (kUTTypeTIFF) の代わりに gif (kUTTypeGIF) を書き出すと、すべてうまくいきます。
ここに私が何をしているかを示すコードが少しあります... (Xcode 4.1 CoreFoundation を使用) 以下のコードは、3 つの JPEG 画像を取り込み、マルチレイヤー tiff ファイルを書き出す個別のレイヤーを作成する必要があります。GIF では正常に機能しますが、TIFF では機能しません。
// create CFURLRef for 3 separate images.
NSString *filePath1 = [[NSBundle mainBundle] pathForResource:@"1image" ofType:@"jpg"];
CFURLRef url1 = (CFURLRef)[NSURL fileURLWithPath:filePath1];
NSString *filePath2 = [[NSBundle mainBundle] pathForResource:@"2image" ofType:@"jpg"];
CFURLRef url2 = (CFURLRef)[NSURL fileURLWithPath:filePath2];
NSString *filePath3 = [[NSBundle mainBundle] pathForResource:@"3image" ofType:@"jpg"];
CFURLRef url3 = (CFURLRef)[NSURL fileURLWithPath:filePath3];
// setup to write to data object
NSMutableData * finalImageData = [NSMutableData data];
CGImageSourceRef imageSourceRef = nil;
// this one does not work
CGImageDestinationRef imageDestRef = CGImageDestinationCreateWithData((CFMutableDataRef)finalImageData, kUTTypeTIFF, 3, nil);
// This one works
// CGImageDestinationRef imageDestRef = CGImageDestinationCreateWithData((CFMutableDataRef)finalImageData, kUTTypeGIF, 3, nil);
// build the final image
imageSourceRef = CGImageSourceCreateWithURL(url1, nil);
CGImageDestinationAddImageFromSource(imageDestRef, imageSourceRef, 0, nil);
imageSourceRef = CGImageSourceCreateWithURL(url2, nil);
CGImageDestinationAddImageFromSource(imageDestRef, imageSourceRef, 0, nil);
imageSourceRef = CGImageSourceCreateWithURL(url3, nil);
CGImageDestinationAddImageFromSource(imageDestRef, imageSourceRef, 0, nil);
CGImageDestinationFinalize(imageDestRef);
CFRelease(imageDestRef);
CFRelease(imageSourceRef);
// write out the final image data
[finalImageData writeToFile:@"outfile.tif" atomically:YES];
// [finalImageData writeToFile:@"outfile.gif" atomically:YES];