title: Alpha Images convert to .mov
body: <p>I have been able to create the playing .mov, by following the various <a href="https://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie/3742212#3742212">tutorials</a> on stack.</p>
  
  <p>However, my image contains alpha. </p>
  
  <pre><code>CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
  CGBitmapInfo bitmapInfo = (CGBitmapInfo) kCGImageAlphaNoneSkipLast;
  CGContextRef context = CGBitmapContextCreate(pxdata, size.width,
                                               size.height, 8, 4*size.width, rgbColorSpace,
                                               bitmapInfo);
  </code></pre>
  
  <p>This produces</p>
  
  <p><img src="https://i.stack.imgur.com/mkpKw.png" alt="enter image description here"></p>
  
  <p>I have a feeling, its due to the <code>bitmapInfo</code>, but when I use <code>kCGImageAlphaLast</code> my app crashes with</p>
  
  <p>This error</p>
  
  <p><strong>CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 688 bytes/row.</strong></p>
  
  <p>I'm hoping there is an easy solution, I'm not sure what I'm missing.</p>
  
  <p>Here is my full pixelBufferCode</p>
  
  <pre><code>- (CVPixelBufferRef) pixelBufferFromCGImage: (CGImageRef) image {
  
      CGSize size = CGSizeMake(self.imageWidth, self.imageHeight);
  
      NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                               [NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,
                               [NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey,
                               nil];
      CVPixelBufferRef pxbuffer = NULL;
  
      CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault,
                                            size.width,
                                            size.height,
                                            kCVPixelFormatType_32ARGB,
                                            (__bridge CFDictionaryRef) options,
                                            &amp;pxbuffer);
      if (status != kCVReturnSuccess){
          NSLog(@"Failed to create pixel buffer");
      }
  
      NSParameterAssert(status == kCVReturnSuccess &amp;&amp; pxbuffer != NULL);
  
  
      CVPixelBufferLockBaseAddress(pxbuffer, 0);
      void *pxdata = CVPixelBufferGetBaseAddress(pxbuffer);
      NSParameterAssert(pxdata != NULL);
  
      CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
      CGBitmapInfo bitmapInfo = (CGBitmapInfo) kCGImageAlphaLast;
      CGContextRef context = CGBitmapContextCreate(pxdata, size.width,
                                                   size.height, 8, 4*size.width, rgbColorSpace,
                                                   bitmapInfo);
      //kCGImageAlphaNoneSkipFirst);
      NSParameterAssert(context);
      CGContextConcatCTM(context, CGAffineTransformMakeRotation(0));
      CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image),
                                             CGImageGetHeight(image)), image);
      CGColorSpaceRelease(rgbColorSpace);
      CGContextRelease(context);
  
      CVPixelBufferUnlockBaseAddress(pxbuffer, 0);
  
      return pxbuffer;
  }
  </code></pre>