【发布时间】:2015-05-01 14:41:49
【问题描述】:
我正在与 AV Foundation 合作,我正在尝试保存一个特定的 在某个变量中将 CMSampleBufferRef 输出为 UIImage。我正在使用manatee works 示例代码,它使用
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange 为
kCVPixelBufferPixelFormatTypeKey
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[captureOutput setVideoSettings:videoSettings];
但是当我保存图像时,输出只是零或ImageView 的背景。我也尝试不设置输出设置,只使用默认但无用的任何设置。图像仍未渲染。我还尝试设置kCVPixelFormatType_32BGRA,但随后海牛停止检测条形码。
我正在使用苹果on developer website提供的示例代码中的上下文设置
// Create a bitmap graphics context with the sample buffer data
CGContextRef context = CGBitmapContextCreate(NULL,
CVPixelBufferGetWidth(imageBuffer),
CVPixelBufferGetHeight(imageBuffer),
8,
0,
CGColorSpaceCreateDeviceRGB(),
kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
// Create a Quartz image from the pixel data in the bitmap graphics context
CGImageRef quartzImage = CGBitmapContextCreateImage(context);
有人可以帮我解决这里出了什么问题吗?它应该很简单,但我对 AVFoundation 框架没有太多经验。这是上下文使用CGColorSpaceCreateDeviceRGB() 时的一些色彩空间问题吗?
如果需要,我可以提供更多信息。我搜索了 StackOverflow,有很多关于此的条目,但没有一个能解决我的问题
【问题讨论】:
标签: ios objective-c uiimage avfoundation