Skip to content

Commit dfd5626

Browse files
author
shenli.cs
committed
fix log size problem
1 parent 78f6545 commit dfd5626

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example
2+
qrcode.png

lib/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ var QRCode = React.createClass({
105105
var image = document.createElement('img');
106106
image.src = this.props.logo;
107107
image.onload = function () {
108-
var dx = size / 2 - size * 0.1;
109108
var dwidth = size * 0.2;
110-
ctx.drawImage(image, dx, dx, dwidth, dwidth);
109+
var dx = (size - dwidth) / 2;
110+
var dheight = image.height / image.width * dwidth;
111+
var dy = (size - dheight) / 2;
112+
image.width = dwidth;
113+
image.height = dheight;
114+
ctx.drawImage(image, dx, dy, dwidth, dheight);
111115
}
112116
}
113117
},

0 commit comments

Comments
 (0)