title: CIImage to CMSampleBufferRef conversion
body: <p>I am using captureStillImageAsynchronouslyFromConnection: to get image sample buffer from a camera. After that I am running the image through an OpenGL (GPU) to apply filters but unfortunately someone at Apple have put camera on iPhone 4 which output is bigger than the maximum texture size.</p>
  
  <p>Brad Larsons explanation: The iPhone 4 is a special case, in that it can take photos large enough (2592x1936) that they just exceed the maximum texture size of the GPU on those devices (2048x2048). This causes the processing to fail, currently. All other devices either don't take photos that large, or support larger texture sizes (the iPad 2, iPad 3, and iPhone 4S support these larger sizes).</p>
  
  <p>so the code I have is scaling down the image but I have to create CMSampleBufferRef after resizing on iPhone 4 only to cheat the capture process ... anyone knows how to get the CMSampleBufferRef from CIImage?</p>
  
  <p><code>Objective-C
  CIImage *ciImage = [CIImage imageWithCVPixelBuffer:CMSampleBufferGetImageBuffer(sampleBuffer)
                                             options:[NSDictionary dictionaryWithObjectsAndKeys:[NSNull null], kCIImageColorSpace, nil]];
  ciImage = [[ciImage imageByApplyingTransform:myScaleTransform] imageByCroppingToRect:myRect];
  </code></p>