diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/src/components/renderer/RendererResImage.js b/src/components/renderer/RendererResImage.js index f3c4887..6633206 100644 --- a/src/components/renderer/RendererResImage.js +++ b/src/components/renderer/RendererResImage.js @@ -11,6 +11,8 @@ function listPoints(qrcode, params) { const pointList = new Array(nCount); let alignType = params[1]; let timingType = params[2]; + let otherColor = params[3]; + let posColor = params[4]; let id = 0; for (let x = 0; x < nCount; x++) { @@ -19,21 +21,21 @@ function listPoints(qrcode, params) { if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER) { if (qrcode.isDark(x, y)) { if (alignType === 2) { - pointList.push() + pointList.push() } else { - pointList.push() + pointList.push() } } else { if (alignType === 0) { pointList.push() } else { - pointList.push() + pointList.push() } } } else if (typeTable[x][y] == QRPointType.TIMING) { if (qrcode.isDark(x, y)) { if (timingType === 2) { - pointList.push() + pointList.push() } else { pointList.push() } @@ -41,24 +43,22 @@ function listPoints(qrcode, params) { if (timingType === 0) { pointList.push() } else { - pointList.push() + pointList.push() } } } else if (typeTable[x][y] == QRPointType.POS_CENTER) { if (qrcode.isDark(x, y)) { - pointList.push() + pointList.push() } } else if (typeTable[x][y] == QRPointType.POS_OTHER) { if (qrcode.isDark(x, y)) { - pointList.push() + pointList.push() } else { - pointList.push() + pointList.push() } } else { if (qrcode.isDark(x, y)) { pointList.push() - } else { - pointList.push() } } } @@ -94,6 +94,16 @@ function getParamInfo() { "黑白", ] }, + { + type: ParamTypes.COLOR_EDITOR, + key: '信息点颜色', + default: '#000000' + }, + { + type: ParamTypes.COLOR_EDITOR, + key: '定位点颜色', + default: '#000000' + }, ]; } @@ -105,8 +115,6 @@ export function getViewBox(qrcode) { } function getGrayPointList(imgBase64, size, black, white) { - console.log(1) - let canvas = document.createElement('canvas'); let ctx = canvas.getContext('2d'); let img = document.createElement('img'); @@ -127,7 +135,7 @@ function getGrayPointList(imgBase64, size, black, white) { let imageData = ctx.getImageData(x, y, 1, 1); let data = imageData.data; let gray = gamma(data[0], data[1], data[2]); - if (Math.random() > gray / 255) gpl.push(); + if (Math.random() > gray / 255 && ( x % 3 !== 1 || y % 3 !== 1 ) ) gpl.push(); } } resolve(gpl); @@ -136,6 +144,9 @@ function getGrayPointList(imgBase64, size, black, white) { } const RendererResImage = ({qrcode, params, setParamInfo}) => { + let otherColor = params[3]; + let posColor = params[4]; + useEffect(() => { setParamInfo(getParamInfo()); }, [setParamInfo]); @@ -149,10 +160,12 @@ const RendererResImage = ({qrcode, params, setParamInfo}) => { - - - - + + + + + + {gpl.concat(listPoints(qrcode, params))} diff --git a/src/utils/util.js b/src/utils/util.js index 50ae3e5..bc0d4a4 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -66,7 +66,7 @@ export function toBase64(file, width, height) { ctx.fillRect(0, 0, width, height) ctx.drawImage(img, 0, 0, width, height); - resolve(canvas.toDataURL(file.type, 0.8)); + resolve(canvas.toDataURL(file.type, 0.9)); }; }) }