Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add icon to qrcode #291

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ var qrcode = new QRCode(document.getElementById("qrcode"), {
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
correctLevel : QRCode.CorrectLevel.H,
icon:{
src:"" //image base64,
width:25, // default 20px
height:25 // default 20px
}
});
</script>
```
Expand Down
11 changes: 9 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
<script type="text/javascript" src="qrcode.js"></script>
</head>
<body>
<input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" /><br />
<input id="text" type="text" value="https://www.processon.com" style="width:80%" /><br />
<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>

<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 100,
height : 100
height : 100,
colorDark:"#63abf7",
icon:{
//image base64
src:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAACJgSURBVHgB7d1bjFXXnefx/z5VXBKoguABkqJNcNqoygaPy2PDaIydcFH3KC2NKGusdB7iNkSjluxI4+ShTaxEEzyalgV5iB2p8cw8DCD7oXsUyfAy0xcZiGPcUrCVig2maNxtghvcxm26qAIHquqc3ft/ioOroC5nr7P23mut/f1IpMpcYnPWf+/fWv+1L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qe9lYBwC31O8yT/Y8Wm1b3fT/aVfP4edWtc1tO8zrcAHAEVF8Jh6JHnl309NW7+GzHiCKEAEAV8S/ro7W+lq52mo6LV2FNR39D50zMuc+HnsCAMXRx5NcGf3txizCQ2WyAplozeu7vpvk1I/YFwGAfOh+hz4YMe2zrQz+PdmjpQUAeYmP6Os3slp1TJRLgDSs/cWunXFUeYrVCADYldeq46Z/Z77qq5E5lZ3Jv/pxAQBYkN+qY6LcA6Rh7S+e2xjrjYe0tQDAUHwkimvPHn/4mSNSgMICpOHuo7u3Jf8RPyJIAKBJUXwmqtW2FxUcN/4zxBH1IIkl2R+RXgEATKHYFcfNnAmQhnprK6psY48EAK5vjkdyIKpV97sSHA3OBUiDbrZX5rZtjOI4CZJoowBAqcRHkv85eGX0t/vObNo5KA5yNkAmaoRJ8u3WSiwbYxEuAwYQlOuX4eqzqpwOjYm8CJCbXW9z9cZR9LVI90zYgAfgm1jOxBXpT7osP0/2Nfpda081w8sAudmqwzsXL2yf11sPlThZnVSie5NBSVYp0WLRf44IGAD5qa8mYhlfQeiTcKPojEjtUlu10h9H1TOXx671+7DCmM2/AgKRzjeq1X3rAAAAAElFTkSuQmCC',
width:22, // default 20px
height:22 // default 20px
}
});

function makeCode () {
Expand Down
49 changes: 40 additions & 9 deletions qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,32 @@ var QRCode;
this._el.appendChild(this._elImage);
this._bSupportDataURI = null;
};

/**
* Draw a Icon on QRCode
*
* @param {QRCode} oQRCode
*/
Drawing.prototype.drawIcon = function (oQRCode) {
var _htOption = this._htOption;
var _oContext = this._oContext;
var _canvasWidth = _htOption.width;
var _canvasHeight = _htOption.height;
//draw icon
if(_htOption.icon && _htOption.icon.src){
var _imageW = parseInt(_htOption.icon.width || 20);
var _imageH = parseInt(_htOption.icon.height || 20);
var image = new Image();
image.src = _htOption.icon.src;
image.onload = function(){
var _imageX = _canvasWidth / 2 - _imageW / 2;
var _imageY = _canvasHeight / 2 - _imageH / 2;
var _baseVal = 2;
_oContext.fillStyle = "#ffffff";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_oContext.fillStyle = "#ffffff";
_oContext.fillStyle = _htOption.colorLight;

_oContext.fillRect(_imageX - _baseVal, _imageY - _baseVal, _imageW + _baseVal * 2, _imageH + _baseVal * 2);
_oContext.drawImage(this, _imageX, _imageY, _imageW, _imageH);
};
}
};
/**
* Draw the QRCode
*
Expand All @@ -377,13 +402,13 @@ var QRCode;
var _elImage = this._elImage;
var _oContext = this._oContext;
var _htOption = this._htOption;

var _canvasWidth = _htOption.width;
var _canvasHeight = _htOption.height;
var nCount = oQRCode.getModuleCount();
var nWidth = _htOption.width / nCount;
var nHeight = _htOption.height / nCount;
var nWidth = _canvasWidth / nCount;
var nHeight = _canvasHeight / nCount;
var nRoundedWidth = Math.round(nWidth);
var nRoundedHeight = Math.round(nHeight);

_elImage.style.display = "none";
this.clear();

Expand Down Expand Up @@ -413,8 +438,6 @@ var QRCode;
);
}
}

this._bIsPainted = true;
};

/**
Expand Down Expand Up @@ -583,8 +606,16 @@ var QRCode;
this._oQRCode.addData(sText);
this._oQRCode.make();
this._el.title = sText;
this._oDrawing.draw(this._oQRCode);
this.makeImage();
var that = this;
var pro = new Promise(function(resolve, reject){
that._oDrawing.draw(that._oQRCode);
that._oDrawing.drawIcon(that._oQRCode);
resolve();
});
pro.then(function(){
that._bIsPainted = true;
that.makeImage();
})
};

/**
Expand Down