title: How to save raw image data to png image?
body: <p>Currently I have a <a href="https://github.com/tyduptyler13/RayTracer" rel="nofollow noreferrer">ray-tracing program</a> that produces RGB values in floating point (from 0 to 1) or <code>short</code> values (from 0 to 255).  (The relevant code is in <a href="https://github.com/tyduptyler13/RayTracer/blob/master/render/ImageTools.cpp" rel="nofollow noreferrer">ImageTools.cpp</a> and <a href="https://github.com/tyduptyler13/RayTracer/blob/master/render/ImageTools.hpp#L210" rel="nofollow noreferrer">ImageTools.hpp</a>.)</p>
  
  <p>Currently I can produce images by writing <a href="http://netpbm.sourceforge.net/doc/ppm.html" rel="nofollow noreferrer">PPM</a>, which is horrendously large and bloated.</p>
  
  <p>How can I write a PNG image from one of these arrays?</p>
  
  <p>I prefer not to add a dependency on anything that's not commonly installed on most Linux systems, as I have 0 dependencies so far.</p>