-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
135 lines (125 loc) · 5.17 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
<head>
<title>Display a JPEG image</title>
<meta charset="UTF-8">
<script src="reader.js"></script>
<script src="hufftree.js"></script>
<script src="huffarray.js"></script>
<script src="idct.js"></script>
<script src="jsjpeg.js"></script>
<script src="test.js"></script>
<style>
.imgholder{
padding: 10px;
}
.imgholder.input, imgholder.output {
float: left;
}
</style>
</head>
<body>
<input type="file" accept="image/jpeg" id="inputImg" onchange="loadFile(event, 'original')">
<!-- Adapted from https://stackoverflow.com/questions/4459379/preview-an-image-before-it-is-uploaded -->
<script>
var maxWidth = 500;
var loadFile = function(event, targetID) {
var original = document.getElementById(targetID);
original.src = URL.createObjectURL(event.target.files[0]);
original.onload = function() {
URL.revokeObjectURL(original.src); // free memory
let canvas = document.getElementById("originalCanvas");
let width = (this.width < maxWidth ? this.width : maxWidth);
let height = this.height * (width / this.width);
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
context = canvas.getContext('2d');
context.drawImage(original, 0, 0, this.width, this.height, 0, 0, width, height);
document.getElementById("orighsize").textContent = width;
document.getElementById("origvsize").textContent = height;
readFile(event.target.files[0]);
}
};
</script>
<div class="container">
<p>Select Huffman Decoder implementation:<br>
<input type="radio" name="huffmanType" value="array" id="huffArray" checked>
<label for="huffArray">Array (default, from JPEG spec)</label>
<br>
<input type="radio" name="huffmanType" value="tree" id="huffTree">
<label for="huffTree">Binary Tree</label>
</p>
</div>
<div class="container">
<p>Select IDCT implementation:<br>
<input type="radio" name="idctType" value="calculated" id="idctCalc" checked>
<label for="idctCalc">Naïve implementation (no caching)</label>
<br>
<input type="radio" name="idctType" value="cached" id="idctCached">
<label for="idctCached">Use pre-calculated values (faster)</label>
<br>
<input type="radio" name="idctType" value="chenwang" id="idctChenWang">
<label for="idctChenWang">Chen-Wang algorithm</label>
</p>
</div>
<div class="container">
<p>Select Colorspace Conversion implementation:<br>
<input type="radio" name="colorConvType" value="float" id="colorConvFloat" checked>
<label for="colorConvFloat">Floating-point (JFIF spec)</label>
<br>
<input type="radio" name="colorConvType" value="integer" id="colorConvInteger">
<label for="colorConvInteger">Integer</label>
</p>
</div>
<div class="container">
<div class="imgholder input">
<p>Reference image (decoded by browser)<br>
Width: <span id="orighsize"></span><br>
Height: <span id="origvsize"></span></p>
<img id="original" src="#" style="display: none">
<canvas id="originalCanvas"></canvas>
</div>
<div class="imgholder output">
<p>Decoded image<br>
Width: <span id="outputhsize"></span><br>
Height: <span id="outputvsize"></span></p>
<canvas id="outputCanvas"></canvas>
</div>
</div>
<div class="container">
<div class="imgholder component">
<p>Component 1<br>
Width: <span id="component1hsize"></span><br>
Height: <span id="component1vsize"></span></p>
<canvas id="component1Canvas"></canvas>
<canvas id="component1ScaledCanvas"></canvas>
</div>
</div>
<div class="container">
<div class="imgholder component">
<p>Component 2<br>
Width: <span id="component2hsize"></span></br>
Height: <span id="component2vsize"></span></p>
<canvas id="component2Canvas"></canvas>
<canvas id="component2ScaledCanvas"></canvas>
</div>
</div>
<div class="container">
<div class="imgholder component">
<p>Component 3<br>
Width: <span id="component3hsize"></span><br>
Height: <span id="component3vsize"></span></p>
<canvas id="component3Canvas"></canvas>
<canvas id="component3ScaledCanvas"></canvas>
</div>
</div>
<div class="container">
<div class="imgholder component">
<p>Component 4<br>
Width: <span id="component4hsize"></span><br>
Height: <span id="component4vsize"></span></p>
<canvas id="component4Canvas"></canvas>
<canvas id="component4ScaledCanvas"></canvas>
</div>
</div>
</body>
</html>