This article recommends [TOOLFK] online QR code decoding, online QR code decoder , you can get the QR code by dragging or uploading the QR code picture, computer camera scanning the QR code, entering the QR code picture address, etc. Content.
Website name: ToolFk
website link: https://www.toolfk.com/Tool
link: https://www.toolfk.com/tool-generate-qrcode?t=qrdecode
website link: https://www.toolfk.com/Tool
link: https://www.toolfk.com/tool-generate-qrcode?t=qrdecode
Code teaching
The code base that this tool [online QR code decoding tool] depends on is
https://github.com/davidshimjs/qrcodejs
STEP 1
STEP 2
The core code is as follows
function renderLogo(canvas, url){
var img = new Image(),
ctx = canvas.getContext('2d'),
canvasSize = 200;
if (!url) {
ctx.fillStyle = 'rgb(255, 255, 255)';
ctx.fillRect(0, 0, canvasSize, canvasSize);
return;
}
img.onload = function (){
var imgSize, zoom,
imgW = img.width, imgH = img.height;
canvas.width = canvasSize;
canvas.height = canvasSize;
ctx.fillStyle = 'rgb(255, 255, 255)';
ctx.fillRect(0, 0, canvasSize, canvasSize);
imgSize = Math.max(imgW, imgH);
if (imgSize > canvasSize) {
zoom = canvasSize / imgSize;
imgW = imgW * zoom;
imgH = imgH * zoom;
}
ctx.drawImage(img, (canvasSize - imgW) / 2, (canvasSize - imgH) / 2, imgW, imgH);
};
$('#decode-btn').on('click', function (e){
e.preventDefault();
$('#decode-text').val("");
try{
result = $('#decode-canvas').QRDecode(function (e){
layer.msg(e.message);
throw e;
});
}catch(err){
return layer.msg(err.message);
}
if (result) {
$('#decode-text').val(result);
}
});
留言
發佈留言