title: Display Image in QML from response to XmlHttpRequest (REST)
body: <p>I need to fetch a jpeg image from a REST API call. I use XMLHttpRequest as the request requires authentication headers (i.e. I can't just create an Image and set the source to the URL with user:passwd@url).</p>
  
  <p>I thought I'd be able to use a Canvas and call drawImage by setting the REST data to a CanvasImageData object. However, it doesn't draw anything, nor does it produce an error. The REST call returns Content-Type: image/jpeg and the Transfer-Encoding: chunked.</p>
  
  <p>Should this approach work, or am I missing something else? Any better suggestions?</p>
  
  <pre><code>// map_request.imageBytes is a property that holds the binary response from the REST query
  Canvas {
  id: location_map
  width: 2400
  height: 1500
  contextType: '2d'
  
  onPaint: {
    if (context &amp;&amp; map_request.imageBytes)
    {
      var cid = context.createImageData(width, height);
      cid.data = map_request.imageBytes;
      context.drawImage(cid, 0, 0);
    }
  }
  </code></pre>