title: Send generated image to browser using Play framework
body: <p>I'm trying to output a generated image using Play. I'm not sure if my issue is Play-specific or not.  I'm trying to do the same thing this PHP code does:</p>
  
  <pre><code>header("Content-type: Image/png");
  $map = imagecreatefrompng("$_SESSION[ROOT]/it/cabling/maps/${building}_$floor.png");
  ... // add annotations
  imagepng($map);
  </code></pre>
  
  <p>It looks like I need to use <code>renderBinary</code>, but I'm not sure how to get from a <code>BufferedImage</code> to the <code>InputStream</code> that <code>renderBinary</code> wants as its argument.</p>
  
  <p><code>Application.map</code> action:</p>
  
  <pre><code>public static void map(String building_code, String ts_code) throws IOException {
      BufferedImage image = ImageIO.read(new File("public/images/maps/" + building_code + "_" + ts_code.charAt(0)));
      ... // Overlay some additional information on the image
      // do some sort of conversion
      renderBinary(inputStream);
  }
  </code></pre>