Commit 2c4623bd authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

fixed regular jpegs display

parent c24f15cc
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
// working time // working time
var T0; var T0;
var TX;
var BAYER = settings.mosaic; var BAYER = settings.mosaic;
var FLIPV = 0; var FLIPV = 0;
...@@ -81,6 +82,9 @@ ...@@ -81,6 +82,9 @@
//reset format //reset format
IMAGE_FORMAT = "JPEG"; IMAGE_FORMAT = "JPEG";
TX = Date.now();
T0 = Date.now();
var http = new XMLHttpRequest(); var http = new XMLHttpRequest();
var rq = ""; var rq = "";
...@@ -90,11 +94,16 @@ ...@@ -90,11 +94,16 @@
}else{ }else{
rq = settings.image; rq = settings.image;
} }
http.open("GET", rq, true); http.open("GET", rq, true);
http.responseType = "blob"; http.responseType = "blob";
http.onload = function(e) { http.onload = function(e) {
console.log("#"+elem.attr("id")+", file load time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
if (this.status === 200) { if (this.status === 200) {
var heavyImage = new Image(); var heavyImage = new Image();
heavyImage.onload = function(){ heavyImage.onload = function(){
...@@ -125,9 +134,18 @@ ...@@ -125,9 +134,18 @@
$(this).draw({ $(this).draw({
fn: function(ctx){ fn: function(ctx){
T0 = Date.now(); console.log("#"+elem.attr("id")+", raw image drawn time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
if ((IMAGE_FORMAT=="JP4")||(IMAGE_FORMAT=="JP46")){ if (IMAGE_FORMAT=="JPEG"){
// if JP4/JP46 it will work through webworker and exit later on workers message
Elphel.Canvas.drawScaled(cnv_working,cnv_display,settings.width);
$(this).trigger("canvas_ready");
}else if ((IMAGE_FORMAT=="JP4")||(IMAGE_FORMAT=="JP46")){
if (settings.fast){ if (settings.fast){
quickestPreview(ctx); quickestPreview(ctx);
}/*else{ }/*else{
...@@ -185,6 +203,9 @@ ...@@ -185,6 +203,9 @@
var image = ctx.getImageData(0,0,width,height); var image = ctx.getImageData(0,0,width,height);
var pixels = image.data; var pixels = image.data;
console.log("#"+elem.attr("id")+", data from canvas for webworker time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
worker.postMessage({ worker.postMessage({
mosaic: settings.mosaic, mosaic: settings.mosaic,
format: IMAGE_FORMAT, format: IMAGE_FORMAT,
...@@ -207,11 +228,14 @@ ...@@ -207,11 +228,14 @@
var width = e.data.width; var width = e.data.width;
var height = e.data.height; var height = e.data.height;
console.log("#"+elem.attr("id")+", worker time: "+(Date.now()-TX)/1000+" s");
TX = Date.now();
Elphel.Canvas.putImageData(working_context,pixels,width,height); Elphel.Canvas.putImageData(working_context,pixels,width,height);
Elphel.Canvas.drawScaled(cnv_working,cnv_display,settings.width); Elphel.Canvas.drawScaled(cnv_working,cnv_display,settings.width);
// report time // report time
console.log("#"+elem.attr("id")+", time: "+(Date.now()-T0)/1000+" s"); console.log("#"+elem.attr("id")+", Total time: "+(Date.now()-T0)/1000+" s");
//trigger here //trigger here
cnv_working.trigger("canvas_ready"); cnv_working.trigger("canvas_ready");
} }
......
...@@ -12,22 +12,31 @@ self.onmessage = function(e) { ...@@ -12,22 +12,31 @@ self.onmessage = function(e) {
var Pixels = new Uint8Array(e.data.pixels); var Pixels = new Uint8Array(e.data.pixels);
var reorderedPixels = Elphel.Pixels.reorderBlocksJPx(Pixels,W,H,Format,Mosaic,settings.fast); if (Format!="JPEG"){
var reorderedPixels = Elphel.Pixels.reorderBlocksJPx(Pixels,W,H,Format,Mosaic,settings.fast);
//reorder first then downscale //reorder first then downscale
if (settings.fast){ if (settings.fast){
W = W/2; W = W/2;
H = H/2; H = H/2;
}
Elphel.Pixels.applySaturation(reorderedPixels,W,H,2);
postMessage({
width: W,
height: H,
pixels: reorderedPixels.buffer
},[reorderedPixels.buffer]);
}else{
//just send back
postMessage({
width: W,
height: H,
pixels: Pixels.buffer
},[Pixels.buffer]);
} }
Elphel.Pixels.applySaturation(reorderedPixels,W,H,2);
postMessage({
width: W,
height: H,
pixels: reorderedPixels.buffer
},[reorderedPixels.buffer]);
//Elphel.test();
}; };
\ No newline at end of file
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