由于Snow Leopard,QTKit现在正在从QTMovies frameImageAtTime:withAttributes:error:返回色彩校正图像数据。给定一个未压缩的AVI文件,相同的图像数据在Snow Leopard vs. Leopard中以更大的像素值显示。如何从雪豹的QTKit中获取图像数据而无需颜色或伽马校正?
目前,我正在使用frameImageAtTime来获取NSImage,然后请求该图像的tiffRepresentation。完成此操作后,雪豹的像素值稍高。
例如,在豹以下像素值的文件:
[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];
这并转换回的“非色彩校正'colorspace,但颜色值NOT与存储在我们正在测试的未压缩AVI文件中的值完全相同。而且这样效率低得多,因为它是从RGB转换到“Device RGB” - > RGB。
另外,我正在使用64位应用程序,因此不能选择下载到Quicktime-C API。
感谢您的帮助。
你的位图中像素的目的地是什么?你从[位图颜色空间]得到什么样的色彩空间? – 2012-01-03 00:37:31