title: CGImageCreateWithMaskingColors returns nil
body: <p>Help!</p>
  
  <p>I've searched extensively and I haven't found a solution to this "simple" problem.  What I am attempting to do is replace white pixels with alpha.  It looks like <code>CGImageCreateWithMaskingColors</code> should give me what I want, unfortunately it returns nil in every case.  Here's my code, what am I doing wrong?</p>
  
  <pre><code>CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  
  CGContextRef context = CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, colorSpace, kCGImageAlphaPremultipliedFirst);
  
  //draw a black background
  CGContextSetRGBFillColor(context,0,0, 0, 1);
  
  CGContextFillRect(context, CGRectMake(0, 0, size.width, size.height));
  
  char* text2 = (char *)[text cStringUsingEncoding:NSASCIIStringEncoding];
  
  CGContextSelectFont(context, "Helvetica Bold", kFontSize, kCGEncodingMacRoman);
  
  CGContextSetTextDrawingMode(context, kCGTextFill);
  
  //draw text with the "alpha" color white)
  CGContextSetRGBFillColor(context, 1, 1, 1, 1);
  
  float textLength = 20;
  
  CGContextShowTextAtPoint(context, (size.width/2)-(textLength/2), ((size.height/2)-(kFontSize/2))+5, text2, strlen(text2));
  
  //create the black/white image
  
  CGImageRef alphaMask = CGBitmapContextCreateImage(context);
  
  const float colorMasking[6] = {0xEE, 0xFF, 0xEE, 0xFF, 0xEE, 0xFF};
  
  CGImageRef imageMasked = CGImageCreateWithMaskingColors(alphaMask, colorMasking);
  </code></pre>
  
  <p><code>imageMasked</code> is <code>nil</code> no matter what I try.  I would appreciate any help you can provide, thanks!</p>