title: Creating an NSImage from bitmap data
body: <p>Ok, it appears that the I'm creating a PDFDocument where pixelWidth is incorrect in the images that I created. So the question becomes: How do I get the correct resolution into the image?</p>
  
  <p>I start with bitmap data from a scanner. I'm doing this:</p>
  
  <pre><code>CGDataProviderRef provider= CGDataProviderCreateWithData(NULL (UInt8*)data, bytesPerRow * length, NULL);
  CGImageRef cgImg =  CGImageCreate (
      width,
      length,
      bitsPerComponent,
      bitsPerPixel,
      bytesPerRow,
      colorspace,
      bitmapinfo, // ?        CGBitmapInfo bitmapInfo,
      provider,   //? CGDataProviderRef provider,
      NULL, //const CGFloat decode[],
      true, //bool shouldInterpolate,
      kCGRenderingIntentDefault // CGColorRenderingIntent intent
      );
  /*  CGColorSpaceRelease(colorspace); */
  
  NSData* imgData = [NSMutableData data];
  CGImageDestinationRef dest = CGImageDestinationCreateWithData
      (imgData, kUTTypeTIFF, 1, NULL);
  CGImageDestinationAddImage(dest, cgImg, NULL);
  CGImageDestinationFinalize(dest);
  NSImage* img = [[NSImage alloc] initWithData: imgData];
  </code></pre>
  
  <p>there doesn't appear to be anywhere in there to include the actual width/height in inches or points, nor the actual resolution, which I <strong>DO</strong> know at this point... how am I supposed to do this?</p>