kopia lustrzana https://github.com/hughchen/qr_image
Fix icon and clear image context in case multiple images are uploaded
rodzic
ebad938479
commit
a66bc5d512
|
@ -10,7 +10,7 @@
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
|
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
|
||||||
/>
|
/>
|
||||||
<link rel="icon" href="./demo.png" />
|
<link rel="icon" href="./images/demo_squid.png" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<title>QRImage</title>
|
<title>QRImage</title>
|
||||||
|
|
10
index.js
10
index.js
|
@ -7,8 +7,11 @@ imageLoader.addEventListener("change", handleImage, false);
|
||||||
var uploadCanvas = document.getElementById("imageCanvas");
|
var uploadCanvas = document.getElementById("imageCanvas");
|
||||||
var uploadContext = uploadCanvas.getContext("2d");
|
var uploadContext = uploadCanvas.getContext("2d");
|
||||||
|
|
||||||
uploadCanvas.width = 200;
|
uploadWidth = 200;
|
||||||
uploadCanvas.height = 200;
|
uploadHeight = 200;
|
||||||
|
|
||||||
|
uploadCanvas.width = uploadWidth;
|
||||||
|
uploadCanvas.height = uploadHeight;
|
||||||
|
|
||||||
img = false;
|
img = false;
|
||||||
|
|
||||||
|
@ -17,7 +20,8 @@ function handleImage(e) {
|
||||||
reader.onload = function (event) {
|
reader.onload = function (event) {
|
||||||
img = new Image();
|
img = new Image();
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
uploadContext.drawImage(img, 0, 0, 200, 200);
|
uploadContext.clearRect(0, 0, uploadWidth, uploadHeight);
|
||||||
|
uploadContext.drawImage(img, 0, 0, uploadWidth, uploadHeight);
|
||||||
};
|
};
|
||||||
img.src = event.target.result;
|
img.src = event.target.result;
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue