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
037d9a98
Commit
037d9a98
authored
Jun 10, 2019
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switched to UTIF.js form tiff.js
parent
17407d6b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
3 deletions
+48
-3
jquery-jp4.js
src/jp4-canvas/jquery-jp4.js
+48
-3
No files found.
src/jp4-canvas/jquery-jp4.js
View file @
037d9a98
...
...
@@ -197,14 +197,59 @@
var
arrayBuffer
;
var
fileReader
=
new
FileReader
();
fileReader
.
onload
=
function
(
event
){
arrayBuffer
=
event
.
target
.
result
;
var
tiff
=
new
Tiff
({
buffer
:
arrayBuffer
});
var
canvas
=
tiff
.
toCanvas
();
// tiff.js which is limited in capabilities
//var tiff = new Tiff({buffer: arrayBuffer});
//var canvas = tiff.toCanvas();
// UTIF.js
var
ifds
=
UTIF
.
decode
(
arrayBuffer
);
UTIF
.
decodeImage
(
arrayBuffer
,
ifds
[
0
]);
if
(
ifds
[
0
].
t258
==
16
){
rgba_16bit
=
new
Float32Array
(
ifds
[
0
].
data
.
filter
((
x
,
i
)
=>
i
%
2
==
0
));
rgba_16bit
=
rgba_16bit
.
map
((
x
,
i
)
=>
x
+
(
ifds
[
0
].
data
[
2
*
i
+
1
]
<<
8
));
/*
if (ifds[0].height==122){
// cut off telemetry
ifds[0].height = 120;
rgba_16bit = rgba_16bit.slice(0,ifds[0].height*ifds[0].width);
}
*/
// convert to C
rgba_16bit
=
rgba_16bit
.
map
(
x
=>
x
/
100
-
273.15
);
// scale
t_lo
=
10
;
t_hi
=
30
;
rgba_16bit
=
rgba_16bit
.
map
(
x
=>
(
x
-
t_lo
)
/
(
t_hi
-
t_lo
));
rgba_16bit
=
rgba_16bit
.
map
(
x
=>
255
*
x
*
x
);
}
var
rgba_clamped
=
new
Uint8ClampedArray
(
rgba_16bit
.
length
*
4
);
rgba_clamped
=
rgba_clamped
.
map
((
x
,
i
)
=>
rgba_16bit
[(
i
-
i
%
4
)
/
4
]);
rgba_clamped
=
rgba_clamped
.
map
((
x
,
i
)
=>
(
i
%
4
==
3
)?
255
:
x
);
var
rgba_idata
=
new
ImageData
(
rgba_clamped
,
ifds
[
0
].
width
,
ifds
[
0
].
height
);
var
canvas
=
cnv_working
[
0
];
canvas
.
width
=
ifds
[
0
].
width
;
canvas
.
height
=
ifds
[
0
].
height
;
var
ctx
=
canvas
.
getContext
(
'2d'
);
ctx
.
putImageData
(
rgba_idata
,
0
,
0
);
cnv_working
.
trigger
(
"canvas_ready"
);
obj
.
busy
=
false
;
Elphel
.
Canvas
.
drawScaled
(
$
(
canvas
),
cnv_display
,
settings
.
width
);
//Elphel.Canvas.drawScaled($(canvas),cnv_display,settings.width);
Elphel
.
Canvas
.
drawScaled
(
cnv_working
,
cnv_display
,
settings
.
width
);
}
fileReader
.
readAsArrayBuffer
(
blob
);
...
...
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