Iphone CGBitmapContextCreate中出错

Iphone CGBitmapContextCreate中出错,iphone,video-streaming,avfoundation,cgbitmapcontextcreate,cgbitmapcontext,Iphone,Video Streaming,Avfoundation,Cgbitmapcontextcreate,Cgbitmapcontext,我试图从sampleBufferData和控制台中的数据创建UIImage :CGBitmapContextCreate:无效数据字节/行:对于8个整数位/组件、3个组件、KCGIMAGEAlphaPremultipledFirst,应至少为1920。 :CGBitmapContextCreateImage:无效的上下文0x0 这是我的密码 // Create a bitmap graphics context with the sample buffer data CGContextRef c

我试图从sampleBufferData和控制台中的数据创建UIImage

:CGBitmapContextCreate:无效数据字节/行:对于8个整数位/组件、3个组件、KCGIMAGEAlphaPremultipledFirst,应至少为1920。
:CGBitmapContextCreateImage:无效的上下文0x0

这是我的密码

// Create a bitmap graphics context with the sample buffer data
CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8, 
  bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); 
// Create a Quartz image from the pixel data in the bitmap graphics context
CGImageRef quartzImage = CGBitmapContextCreateImage(context);

错误信息似乎很清楚什么是错误的。
CGBitmapContextCreate
的输入参数值是多少?void*baseAddress=CVPixelBufferGetBaseAddress(imageBuffer);//获取像素缓冲区大小的每行字节数\u t bytesPerRow=CVPixelBufferGetBytesPerRow(imageBuffer);//获取像素缓冲区宽度和高度大小\u t width=CVPixelBufferGetWidth(imageBuffer);size_t height=CVPixelBufferGetHeight(imageBuffer);//创建设备相关的RGB颜色空间CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();这是输入,imageBuffer来自//获取媒体数据的CMSampleBuffer的核心视频图像缓冲区CVImageBufferRef imageBuffer=CMSampleBufferGetImageBuffer(sampleBuffer);您应该使用调试器检查这些值,看看它们是否有意义。如果像素缓冲区具有不同的颜色空间或每个组件的位,该怎么办?好的thx Ole为您提供帮助,如果您不介意thx,我将随时向您更新mu状态。错误消息似乎很清楚是怎么回事。
CGBitmapContextCreate
的输入参数值是多少?void*baseAddress=CVPixelBufferGetBaseAddress(imageBuffer);//获取像素缓冲区大小的每行字节数\u t bytesPerRow=CVPixelBufferGetBytesPerRow(imageBuffer);//获取像素缓冲区宽度和高度大小\u t width=CVPixelBufferGetWidth(imageBuffer);size_t height=CVPixelBufferGetHeight(imageBuffer);//创建设备相关的RGB颜色空间CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();这是输入,imageBuffer来自//获取媒体数据的CMSampleBuffer的核心视频图像缓冲区CVImageBufferRef imageBuffer=CMSampleBufferGetImageBuffer(sampleBuffer);您应该使用调试器检查这些值,看看它们是否有意义。如果像素缓冲区具有不同的颜色空间或每个组件的位,该怎么办?好的thx Ole为您提供帮助,如果您不介意thx,我将随时向您更新mu状态