Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-web-393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-web-393
Commits
2c4623bd
Commit
2c4623bd
authored
Apr 12, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed regular jpegs display
parent
c24f15cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
21 deletions
+54
-21
jquery-jp4.js
src/jp4-canvas/jquery-jp4.js
+29
-5
webworker.js
src/jp4-canvas/webworker.js
+25
-16
No files found.
src/jp4-canvas/jquery-jp4.js
View file @
2c4623bd
...
...
@@ -53,6 +53,7 @@
// working time
var
T0
;
var
TX
;
var
BAYER
=
settings
.
mosaic
;
var
FLIPV
=
0
;
...
...
@@ -81,6 +82,9 @@
//reset format
IMAGE_FORMAT
=
"JPEG"
;
TX
=
Date
.
now
();
T0
=
Date
.
now
();
var
http
=
new
XMLHttpRequest
();
var
rq
=
""
;
...
...
@@ -90,11 +94,16 @@
}
else
{
rq
=
settings
.
image
;
}
http
.
open
(
"GET"
,
rq
,
true
);
http
.
responseType
=
"blob"
;
http
.
onload
=
function
(
e
)
{
console
.
log
(
"#"
+
elem
.
attr
(
"id"
)
+
", file load time: "
+
(
Date
.
now
()
-
TX
)
/
1000
+
" s"
);
TX
=
Date
.
now
();
if
(
this
.
status
===
200
)
{
var
heavyImage
=
new
Image
();
heavyImage
.
onload
=
function
(){
...
...
@@ -125,9 +134,18 @@
$
(
this
).
draw
({
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
){
quickestPreview
(
ctx
);
}
/*else{
...
...
@@ -185,6 +203,9 @@
var
image
=
ctx
.
getImageData
(
0
,
0
,
width
,
height
);
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
({
mosaic
:
settings
.
mosaic
,
format
:
IMAGE_FORMAT
,
...
...
@@ -207,11 +228,14 @@
var
width
=
e
.
data
.
width
;
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
.
drawScaled
(
cnv_working
,
cnv_display
,
settings
.
width
);
// 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
cnv_working
.
trigger
(
"canvas_ready"
);
}
...
...
src/jp4-canvas/webworker.js
View file @
2c4623bd
...
...
@@ -12,22 +12,31 @@ self.onmessage = function(e) {
var
Pixels
=
new
Uint8Array
(
e
.
data
.
pixels
);
var
reorderedPixels
=
Elphel
.
Pixels
.
reorderBlocksJPx
(
Pixels
,
W
,
H
,
Format
,
Mosaic
,
settings
.
fast
);
//reorder first then downscale
if
(
settings
.
fast
){
W
=
W
/
2
;
H
=
H
/
2
;
if
(
Format
!=
"JPEG"
){
var
reorderedPixels
=
Elphel
.
Pixels
.
reorderBlocksJPx
(
Pixels
,
W
,
H
,
Format
,
Mosaic
,
settings
.
fast
);
//reorder first then downscale
if
(
settings
.
fast
){
W
=
W
/
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment