Commit c9775573 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: Display intermediate image after get orientation

parent 9a483f3a
...@@ -402,6 +402,7 @@ ...@@ -402,6 +402,7 @@
image_capture = new window.ImageCapture( image_capture = new window.ImageCapture(
gadget.element.querySelector('video').srcObject.getVideoTracks()[0] gadget.element.querySelector('video').srcObject.getVideoTracks()[0]
), ),
canvas = domsugar('canvas', {'class': 'canvas'}),
photo_blob, photo_blob,
div; div;
...@@ -415,17 +416,9 @@ ...@@ -415,17 +416,9 @@
return image_capture.takePhoto({imageWidth: capabilities.imageWidth.max}); return image_capture.takePhoto({imageWidth: capabilities.imageWidth.max});
}) })
.push(function (blob) { .push(function (blob) {
photo_blob = blob;
return jIO.util.readBlobAsDataURL(blob);
})
.push(function (result) {
var img = domsugar("img", {"src": result.target.result});
gadget.detached_promise_dict.media_stream.cancel('Not needed anymore, as captured');
div = gadget.element.querySelector(".camera-input");
div.replaceChild(img, div.firstElementChild);
return RSVP.all([ return RSVP.all([
createImageBitmap(photo_blob), createImageBitmap(blob),
getOrientation(photo_blob) getOrientation(blob)
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
...@@ -433,7 +426,6 @@ ...@@ -433,7 +426,6 @@
orientation = result_list[1], orientation = result_list[1],
height = bitmap.height, height = bitmap.height,
width = bitmap.width, width = bitmap.width,
canvas = domsugar('canvas', {'class': 'canvas'}),
ctx; ctx;
if (4 < orientation && orientation < 9) { if (4 < orientation && orientation < 9) {
...@@ -473,6 +465,15 @@ ...@@ -473,6 +465,15 @@
break; break;
} }
ctx.drawImage(bitmap, 0, 0); ctx.drawImage(bitmap, 0, 0);
return canvas.toDataURL("image/jpeg");
})
.push(function (result) {
var img = domsugar("img", {"src": result});
gadget.detached_promise_dict.media_stream.cancel('Not needed anymore, as captured');
div = gadget.element.querySelector(".camera-input");
div.replaceChild(img, div.firstElementChild);
})
.push(function (result_list) {
if (settings.brightness || settings.contrast || settings.enable_greyscale || settings.compression) { if (settings.brightness || settings.contrast || settings.enable_greyscale || settings.compression) {
return handleCaman(canvas, settings); return handleCaman(canvas, settings);
} }
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.7505.28245.6314</string> </value> <value> <string>982.16570.34450.716</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1582772276.5</float> <float>1583144747.41</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment