title: How to display raw image data with html and javascript?
body: <p>I have an ajax application where the PHP side sends uncoded raw image data, coming from a camera, to the client javascript side.</p>
  
  <p>I would like to display the image via html and javascript using <code>img</code> or <code>canvas</code> tags.</p>
  
  <p>Image data are 32*32 unsigned char.</p>
  
  <p>I would like to do, whatever it takes to reach my goal (encoding or everythig else), but I want to do it at client side beacause I cannot handle any other operation at the server side.</p>
  
  <p>I tried to encode raw data into jpeg or png data but without success.</p>
  
  <p>I post an example that doesn't work:</p>
  
  <pre><code>var encoder = new JPEGEncoder(9);
  var jpgFile = encoder.encode(rawImage, 9);
  document.getElementById("image").src = jpgFile;
  </code></pre>
  
  <p><code>jpgFile</code> is like</p>
  
  <pre><code>data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAFk9Q05DOFlOSE5kXllphd6QhXp6hf/CzaHe//////////////////////////////////////////////////8BXmRkhXWF/5CQ///////////////////////////////////////////////////////////////////////////AABEIAAAAAAMBEQACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AP8A/9k=
  </code></pre>
  
  <p>I got JPEGEncoder googling on internet.</p>