diff --git a/example/ZXingQtWriter.cpp b/example/ZXingQtWriter.cpp index 047f182a7d..bcc1350c00 100644 --- a/example/ZXingQtWriter.cpp +++ b/example/ZXingQtWriter.cpp @@ -4,8 +4,12 @@ // SPDX-License-Identifier: Apache-2.0 #include "BarcodeFormat.h" +#ifdef ZXING_BUILD_EXPERIMENTAL_API +#include "WriteBarcode.h" +#else #include "BitMatrix.h" #include "MultiFormatWriter.h" +#endif #include #include @@ -16,10 +20,14 @@ QImage WriteBarcode(QStringView text, ZXing::BarcodeFormat format) { using namespace ZXing; +#ifdef ZXING_BUILD_EXPERIMENTAL_API + auto barcode = CreateBarcodeFromText(text.toString().toStdString(), format); + auto bitmap = WriteBarcodeToImage(barcode); +#else auto writer = MultiFormatWriter(format); auto matrix = writer.encode(text.toString().toStdString(), 0, 0); auto bitmap = ToMatrix(matrix); - +#endif return QImage(bitmap.data(), bitmap.width(), bitmap.height(), bitmap.width(), QImage::Format::Format_Grayscale8).copy(); } diff --git a/test/blackbox/TestWriterMain.cpp b/test/blackbox/TestWriterMain.cpp index 420f0bf6ca..dd656b857e 100644 --- a/test/blackbox/TestWriterMain.cpp +++ b/test/blackbox/TestWriterMain.cpp @@ -5,7 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 #include "BitMatrix.h" +#ifdef ZXING_BUILD_EXPERIMENTAL_API +#include "WriteBarcode.h" +#else #include "MultiFormatWriter.h" +#endif #include @@ -30,7 +34,11 @@ int main() BarcodeFormat::PDF417, BarcodeFormat::QRCode }) { +#ifdef ZXING_BUILD_EXPERIMENTAL_API + savePng(CreateBarcodeFromText(text, format).symbol(), format); +#else savePng(MultiFormatWriter(format).encode(text, 200, 200), format); +#endif } text = "012345678901234567890123456789"; @@ -47,6 +55,10 @@ int main() {BarcodeFormat::UPCE, 7} })) { auto input = length > 0 ? text.substr(0, length) : text; +#ifdef ZXING_BUILD_EXPERIMENTAL_API + savePng(CreateBarcodeFromText(input, format).symbol(), format); +#else savePng(MultiFormatWriter(format).encode(input, 100, 100), format); +#endif } }