Tweaked QrCodeGeneratorDemo Java code to use QrSegmentAdvanced.makeKanji() instead of hard-coding the data words, while maintaining identical output image.

pull/35/merge
Project Nayuki 7 years ago
parent 49d9301b77
commit 31ba90d0db

@ -137,18 +137,7 @@ public final class QrCodeGeneratorDemo {
qr = QrCode.encodeText(madoka, QrCode.Ecc.LOW);
writePng(qr.toImage(9, 4), "madoka-utf8-QR.png");
int[] kanjiChars = { // Kanji mode encoding (13 bits per character)
0x0035, 0x1002, 0x0FC0, 0x0AED, 0x0AD7,
0x015C, 0x0147, 0x0129, 0x0059, 0x01BD,
0x018D, 0x018A, 0x0036, 0x0141, 0x0144,
0x0001, 0x0000, 0x0249, 0x0240, 0x0249,
0x0000, 0x0104, 0x0105, 0x0113, 0x0115,
0x0000, 0x0208, 0x01FF, 0x0008,
};
BitBuffer bb = new BitBuffer();
for (int c : kanjiChars)
bb.appendBits(c, 13);
segs = Arrays.asList(new QrSegment(QrSegment.Mode.KANJI, kanjiChars.length, bb));
segs = Arrays.asList(QrSegmentAdvanced.makeKanji(madoka));
qr = QrCode.encodeSegments(segs, QrCode.Ecc.LOW);
writePng(qr.toImage(9, 4), "madoka-kanji-QR.png");
}

Loading…
Cancel
Save