-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsample.html
47 lines (35 loc) · 1.34 KB
/
sample.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Image Processing</title>
</head>
<body>
<h1>Image Processing!</h1>
<canvas id="canvas" style="border: solid thin black;"></canvas>
<canvas id="canvas_result" style="border: solid thin black;"></canvas>
<br>
<button onclick="process();" style="margin-left: 90px; font-size: 20px;">process!</button>
<script type="text/javascript">
let image = new Image();
var src = "imori.jpg";
image.src = src;
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
const canvas_result = document.getElementById("canvas_result");
const ctx_result = canvas_result.getContext("2d");
image.onload = () => {
canvas.width = image.width;
canvas.height = image.height;
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
canvas_result.width = image.width;
canvas_result.height = image.height;
}
function process(){
let src = ctx.getImageData(0, 0, image.width, image.height);
let dst = ctx_result.createImageData(image.width, image.height);
ctx_result.putImageData(src, 0, 0);
}
</script>
</body>
</html>