Unsolved Show an Image by loading data via XmlHttpRequest?
-
I need to fetch a jpeg image from a REST API call. I use XMLHttpRequest as the request requires authentication headers (I can't just create an Image and set the source to the URL with user:passwd@url).
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.
Should this approach work, or am I missing something else? Any better suggestions?
-BS
// 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 && map_request.imageBytes) { var cid = context.createImageData(width, height); cid.data = map_request.imageBytes; context.drawImage(cid, 0, 0); } }
-
I x-posted to stackoverflow, and got some suggestions there that addresses the problem.
http://stackoverflow.com/questions/36852856/display-image-in-qml-from-response-to-xmlhttprequest-rest