title: C: Convert array to RGB image
body: <p>In C, I have a 1D array of unsigned chars (ie, between 0 to 255) of length <code>3*DIM*DIM</code> which represents a <code>DIM*DIM</code> pixel image, where the first 3 pixels are the RGB levels of the first pixel, the second 3 pixels are the RGB levels of the second pixel, etc. I would like to save it as a PNG image. What is the easiest, most lightweight method of doing this conversion?</p>
  
  <p>Obviously OpenGL can read and display images of this form (GLUT_RGB), but <code>DIM</code> is larger than the dimensions of my monitor screen, so simply displaying the image and taking a screenshot is not an option.</p>
  
  <p>At the moment, I have been doing the conversion by simply saving the array to a CSV file, loading it in Mathematica, and then exporting it as a PNG, but this is very slow (~8 minutes for a single 7000*7000 pixel image).</p>