title: How can I manipulate the pixel values in a CGImageRef in Xcode
body: <p>I have some </p>
  
  <pre><code>CGImageRef cgImage = "something"
  </code></pre>
  
  <p>Is there a way to manipulate the pixel values of this cgImage? For example if this image contains values between 0.0001 and 3000 thus when I try to view or release the image this way in an NSImageView (<a href="https://stackoverflow.com/questions/23790336/how-can-i-show-an-image-in-a-nsview-using-an-cgimageref-image">How can I show an image in a NSView using an CGImageRef image</a>) </p>
  
  <p>I get a black image, all pixels are black, I think it has to do with setting the pixel range values in a different color map (I don't know).</p>
  
  <p>I want to be able to manipulate or change the pixel values or just be able to see the image by manipulating the color map range.</p>
  
  <p>I have tried this but obviously it doesn't work:</p>
  
  <pre><code>CGContextDrawImage(ctx, CGRectMake(0,0, CGBitmapContextGetWidth(ctx),CGBitmapContextGetHeight(ctx)),cgImage); 
  UInt8 *data = CGBitmapContextGetData(ctx);
  
  for (**all pixel values and i++ **) {
          data[i] = **change to another value I want depending on the value in data[i]**;
          }
  </code></pre>
  
  <p>Thank you, </p>