title: Core Image - rendering a transparent image on CMSampleBufferRef result in black box around it
body: <p>I'm trying to add a watermark/logo on a video that I'm recording using AVFoundation's AVCaptureVideoDataOutput. 
  My class is set as the sampleBufferDelegate and receives the CMSamplebufferRefs. I already apply some effects to the CMSampleBufferRefs CVPixelBuffer and pass it back to the AVAssetWriter.</p>
  
  <p>The logo in the top left corner is delivered using a transparent PNG.
  The problem I'm having is that the transparent parts of the UIImage are black once written to the video.
  Anyone have an idea of what I'm doing wrong or could be forgetting?</p>
  
  <p>Code snippets below:</p>
  
  <pre><code>//somewhere in the init of the class;   
   _eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
  _ciContext = [CIContext contextWithEAGLContext:_eaglContext
                                         options: @{ kCIContextWorkingColorSpace : [NSNull null] }];
  
  //samplebufferdelegate method:
  - (void) captureOutput:(AVCaptureOutput *)captureOutput
   didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
          fromConnection:(AVCaptureConnection *)connection {
  
      CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
      CVPixelBufferLockBaseAddress(pixelBuffer, 0);
  
  ....
  
  UIImage *logoImage = [UIImage imageNamed:@"logo.png"];
  CIImage *renderImage = [[CIImage alloc] initWithCGImage:logoImage.CGImage];
  CGColorSpaceRef cSpace = CGColorSpaceCreateDeviceRGB();
  
  [_ciContext render:renderImage
     toCVPixelBuffer:pixelBuffer
              bounds: [renderImage extent]
          colorSpace:cSpace];
  
  CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
  CGColorSpaceRelease(cSpace);
  
  ....
  }
  </code></pre>
  
  <p>It looks like the CIContext does not draw the CIImages alpha.
  Any ideas?</p>