add PrettyPrintQr for print as real qr on shall

pull/179/head
IU1JFE 2 years ago committed by GitHub
parent 2643e824eb
commit 595e25d482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,7 +46,7 @@ static void doSegmentDemo();
static void doMaskDemo();
static std::string toSvgString(const QrCode &qr, int border);
static void printQr(const QrCode &qr);
static void PrettyPrintQr(const QrCode &qr);
// The main application program.
int main() {
@ -68,7 +68,7 @@ static void doBasicDemo() {
// Make and print the QR Code symbol
const QrCode qr = QrCode::encodeText(text, errCorLvl);
printQr(qr);
PrettyPrintQr(qr);
std::cout << toSvgString(qr, 4) << std::endl;
}
@ -230,3 +230,19 @@ static void printQr(const QrCode &qr) {
}
std::cout << std::endl;
}
// Prints the given QrCode object to the console.
static void PrettyPrintQr(const QrCode &qr)
{
int border = 4;
for (int y = -border; y < qr.getSize() + border; y++)
{
for (int x = -border; x < qr.getSize() + border; x++)
{
std::cout << (qr.getModule(x, y) ? (char)255 : (char)219);
}
std::cout << std::endl;
}
std::cout << std::endl;
}

Loading…
Cancel
Save