-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
46 lines (44 loc) · 1.22 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>zif</title>
</head>
<body>
<h1>ZIF parser</h1>
<form action="#">
<label>ZIF file <input type="file" id="file" /></label>
<label>Zoomlevel <input type="number" value="0" id="zoomlevel" /></label>
<input type="submit" />
</form>
<canvas id="canvas" ></canvas>
<script src="ZIF.js"></script>
<script>
function parse() {
var f=input.files[0];
var ff = new LocalFile(f);
var zif = new ZIF(ff);
zif.getLevel(inputZL.value | 0).then(function (lvl) {
var d = lvl.dimensions();
canvas.width = d[0]; canvas.height = d[1];
var ctx = canvas.getContext("2d");
for(var x = 0; x < lvl.widthInTiles(); x++) {
for(var y = 0; y < lvl.heightInTiles(); y++) {
lvl.getTile(x, y).then(function(blob) {
var img = new Image;
img.src = URL.createObjectURL(blob);
img.onload = function() {
ctx.drawImage(img, this.x*256, this.y*256);
}.bind(this);
}.bind({x:x, y:y}));
}
}
});
}
var input=document.querySelector("#file");
var inputZL=document.querySelector("#zoomlevel");
var c = document.querySelector("canvas");
document.querySelector("form").onsubmit = parse;
</script>
</body>
</html>