2

i'm trying to create UIImage from the sampleBufferData and here what i have in the console

: CGBitmapContextCreate: invalid data bytes/row: should be at least 1920 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
: CGBitmapContextCreateImage: invalid context 0x0

here is my code

// 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);
OXXY
  • 1,047
  • 2
  • 18
  • 43
  • The error message seems pretty clear on what's wrong. What are you values for the input arguments to `CGBitmapContextCreate`? – Ole Begemann Aug 24 '11 at 11:45
  • 1
    void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer); // Get the number of bytes per row for the pixel buffer size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); // Get the pixel buffer width and height size_t width = CVPixelBufferGetWidth(imageBuffer); size_t height = CVPixelBufferGetHeight(imageBuffer); // Create a device-dependent RGB color space CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); here is the inputs – OXXY Aug 24 '11 at 12:07
  • and the imageBuffer is from // Get a CMSampleBuffer's Core Video image buffer for the media data CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); – OXXY Aug 24 '11 at 12:17
  • You should check these values with the debugger and see if they even make sense. What if the pixel buffer has a different color space or bits per component? – Ole Begemann Aug 24 '11 at 12:48
  • ok thx Ole for your help i will keep you updated with mu status if you don't mind thx again – OXXY Aug 24 '11 at 13:11
  • that's right the value is 724 but how can i control it ?? – OXXY Aug 24 '11 at 13:46

0 Answers0