-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkod.js
36 lines (23 loc) · 839 Bytes
/
kod.js
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
let odabirSlike = document.getElementById('odabirSlike');
odabirSlike.addEventListener('change', unosSlike);
kodovanje = document.querySelector('#kodovanje');
noviUnos = document.querySelector('#noviUnos');
kodSlike = document.querySelector('#kodSlike');
function unosSlike(e){
ctx1 = document.getElementById('canvas1');
ctx1 = canvas1.getContext('2d');
img = new Image();
img.src = URL.createObjectURL(e.target.files[0]);
img.onload = function(){
canvas1.width = img.naturalWidth;
canvas1.height = img.naturalHeight;
ctx1.drawImage(img, 0, 0, canvas1.width, canvas1.height);
}
}
kodovanje.addEventListener('click', function(){
kod = canvas1.toDataURL(img);
kodSlike.value = kod;
});
noviUnos.addEventListener('click', function(){
window.location.reload(true);
});