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

pull/134/head
Project Nayuki 3 years ago
parent bff4ea078c
commit 04dd0fc06c

@ -134,18 +134,7 @@ public final class QrCodeGeneratorDemo {
qr = QrCode.encodeText(madoka, QrCode.Ecc.LOW);
writePng(toImage(qr, 9, 4, 0xFFFFE0, 0x303080), "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.data, bb.bitLength));
segs = Arrays.asList(QrSegmentAdvanced.makeKanji(madoka));
qr = QrCode.encodeSegments(segs, QrCode.Ecc.LOW);
writePng(toImage(qr, 9, 4, 0xE0F0FF, 0x404040), "madoka-kanji-QR.png");
}

Loading…
Cancel
Save