Snow Leopard 以降、QTKit は QTMovies frameImageAtTime:withAttributes:error: などの関数から色補正された画像データを返すようになりました。圧縮されていない AVI ファイルを指定すると、Snow Leopard と Leopard では同じ画像データがより大きなピクセル値で表示されます。
現在、frameImageAtTime を使用して NSImage を取得し、その画像の tiffRepresentation を要求しています。これを行うと、Snow Leopard のピクセル値がわずかに高くなります。
たとえば、Leopard で次のピクセル値を持つファイル:
[0 180 0]
次のようなピクセル値があります。
[0 192 0]
色補正されていないビデオ フレームを QTMovie に要求する方法はありますか? 代わりに CGImageRef、CIImage、または CVPixelBufferRef を要求する必要がありますか? ビデオ ファイルを読み込む前に色補正を完全に無効にする方法はありますか?
NSCalibratedColroSpace を使用して NSBitmapImageRep に描画することで、この問題を回避しようとしましたが、それは私の部分しか得られません。
// Create a movie
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys :
nsFileName, QTMovieFileNameAttribute,
[NSNumber numberWithBool:NO], QTMovieOpenAsyncOKAttribute,
[NSNumber numberWithBool:NO], QTMovieLoopsAttribute,
[NSNumber numberWithBool:NO], QTMovieLoopsBackAndForthAttribute,
(id)nil];
_theMovie = [[QTMovie alloc] initWithAttributes:dict error:&error];
// ....
NSMutableDictionary *imageAttributes = [NSMutableDictionary dictionary];
[imageAttributes setObject:QTMovieFrameImageTypeNSImage forKey:QTMovieFrameImageType];
[imageAttributes setObject:[NSArray arrayWithObject:@"NSBitmapImageRep"] forKey: QTMovieFrameImageRepresentationsType];
[imageAttributes setObject:[NSNumber numberWithBool:YES] forKey:QTMovieFrameImageHighQuality];
NSError* err = nil;
NSImage* image = (NSImage*)[_theMovie frameImageAtTime:frameTime withAttributes:imageAttributes error:&err];
// copy NSImage into an NSBitmapImageRep (Objective-C)
NSBitmapImageRep* bitmap = [[image representations] objectAtIndex:0];
// Draw into a colorspace we know about
NSBitmapImageRep *bitmapWhoseFormatIKnow = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:getWidth()
pixelsHigh:getHeight()
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
bytesPerRow:(getWidth() * 4)
bitsPerPixel:32];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmapWhoseFormatIKnow]];
[bitmap draw];
[NSGraphicsContext restoreGraphicsState];
これは「色補正されていない」色空間に変換されますが、色の値は、テストしている非圧縮 AVI ファイルに保存されているものとまったく同じではありません。また、これは RGB -> "Device RGB" -> RGB から変換するため、効率が大幅に低下します。
また、私は 64 ビット アプリケーションで作業しているため、Quicktime-C API にドロップダウンすることはできません。
ご協力いただきありがとうございます。