Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/core/src/WriteBarcode.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright 2022 Axel Waggershauser | |
| 3 */ | |
| 4 // SPDX-License-Identifier: Apache-2.0 | |
| 5 | |
| 6 #pragma once | |
| 7 | |
| 8 #ifdef ZXING_EXPERIMENTAL_API | |
| 9 | |
| 10 #include "Barcode.h" | |
| 11 #include "ImageView.h" | |
| 12 | |
| 13 #include <memory> | |
| 14 #include <string_view> | |
| 15 | |
| 16 extern "C" struct zint_symbol; | |
| 17 | |
| 18 namespace ZXing { | |
| 19 | |
| 20 class CreatorOptions | |
| 21 { | |
| 22 struct Data; | |
| 23 | |
| 24 std::unique_ptr<Data> d; | |
| 25 | |
| 26 friend Barcode CreateBarcode(const void* data, int size, int mode, const CreatorOptions& options); | |
| 27 | |
| 28 public: | |
| 29 CreatorOptions(BarcodeFormat format); | |
| 30 | |
| 31 ~CreatorOptions(); | |
| 32 CreatorOptions(CreatorOptions&&); | |
| 33 CreatorOptions& operator=(CreatorOptions&&); | |
| 34 | |
| 35 zint_symbol* zint() const; | |
| 36 | |
| 37 #define ZX_PROPERTY(TYPE, NAME) \ | |
| 38 TYPE NAME() const noexcept; \ | |
| 39 CreatorOptions& NAME(TYPE v)&; \ | |
| 40 CreatorOptions&& NAME(TYPE v)&&; | |
| 41 | |
| 42 ZX_PROPERTY(BarcodeFormat, format) | |
| 43 ZX_PROPERTY(bool, readerInit) | |
| 44 ZX_PROPERTY(bool, forceSquareDataMatrix) | |
| 45 ZX_PROPERTY(std::string, ecLevel) | |
| 46 | |
| 47 #undef ZX_PROPERTY | |
| 48 }; | |
| 49 | |
| 50 /** | |
| 51 * Generate barcode from unicode text | |
| 52 * | |
| 53 * @param contents UTF-8 string to encode into a barcode | |
| 54 * @param options CreatorOptions (including BarcodeFormat) | |
| 55 * @return #Barcode generated barcode | |
| 56 */ | |
| 57 Barcode CreateBarcodeFromText(std::string_view contents, const CreatorOptions& options); | |
| 58 | |
| 59 /** | |
| 60 * Generate barcode from raw binary data | |
| 61 * | |
| 62 * @param data array of bytes to encode into a barcode | |
| 63 * @param size size of byte array | |
| 64 * @param options CreatorOptions (including BarcodeFormat) | |
| 65 * @return #Barcode generated barcode | |
| 66 */ | |
| 67 Barcode CreateBarcodeFromBytes(const void* data, int size, const CreatorOptions& options); | |
| 68 | |
| 69 #if __cplusplus > 201703L | |
| 70 Barcode CreateBarcodeFromText(std::u8string_view contents, const CreatorOptions& options); | |
| 71 | |
| 72 template <typename R> | |
| 73 requires std::ranges::contiguous_range<R> && std::ranges::sized_range<R> && (sizeof(std::ranges::range_value_t<R>) == 1) | |
| 74 Barcode CreateBarcodeFromBytes(const R& contents, const CreatorOptions& options) | |
| 75 { | |
| 76 return CreateBarcodeFromBytes(std::ranges::data(contents), std::ranges::size(contents), options); | |
| 77 } | |
| 78 #else | |
| 79 template <typename R> | |
| 80 Barcode CreateBarcodeFromBytes(const R& contents, const CreatorOptions& options) | |
| 81 { | |
| 82 return CreateBarcodeFromBytes(std::data(contents), std::size(contents), options); | |
| 83 } | |
| 84 #endif | |
| 85 | |
| 86 // ================================================================================= | |
| 87 | |
| 88 class WriterOptions | |
| 89 { | |
| 90 struct Data; | |
| 91 | |
| 92 std::unique_ptr<Data> d; | |
| 93 | |
| 94 public: | |
| 95 WriterOptions(); | |
| 96 ~WriterOptions(); | |
| 97 WriterOptions(WriterOptions&&); | |
| 98 WriterOptions& operator=(WriterOptions&&); | |
| 99 | |
| 100 #define ZX_PROPERTY(TYPE, NAME) \ | |
| 101 TYPE NAME() const noexcept; \ | |
| 102 WriterOptions& NAME(TYPE v)&; \ | |
| 103 WriterOptions&& NAME(TYPE v)&&; | |
| 104 | |
| 105 ZX_PROPERTY(int, scale) | |
| 106 ZX_PROPERTY(int, sizeHint) | |
| 107 ZX_PROPERTY(int, rotate) | |
| 108 ZX_PROPERTY(bool, withHRT) | |
| 109 ZX_PROPERTY(bool, withQuietZones) | |
| 110 | |
| 111 #undef ZX_PROPERTY | |
| 112 }; | |
| 113 | |
| 114 | |
| 115 /** | |
| 116 * Write barcode symbol to SVG | |
| 117 * | |
| 118 * @param barcode Barcode to write | |
| 119 * @param options WriterOptions to parameterize rendering | |
| 120 * @return std::string SVG representation of barcode symbol | |
| 121 */ | |
| 122 std::string WriteBarcodeToSVG(const Barcode& barcode, const WriterOptions& options = {}); | |
| 123 | |
| 124 /** | |
| 125 * Write barcode symbol to a utf8 string using graphical characters (e.g. '▀') | |
| 126 * | |
| 127 * @param barcode Barcode to write | |
| 128 * @param options WriterOptions to parameterize rendering | |
| 129 * @return std::string Utf8 string representation of barcode symbol | |
| 130 */ | |
| 131 std::string WriteBarcodeToUtf8(const Barcode& barcode, const WriterOptions& options = {}); | |
| 132 | |
| 133 /** | |
| 134 * Write barcode symbol to Image (Bitmap) | |
| 135 * | |
| 136 * @param barcode Barcode to write | |
| 137 * @param options WriterOptions to parameterize rendering | |
| 138 * @return Image Bitmap reprentation of barcode symbol | |
| 139 */ | |
| 140 Image WriteBarcodeToImage(const Barcode& barcode, const WriterOptions& options = {}); | |
| 141 | |
| 142 } // ZXing | |
| 143 | |
| 144 #endif // ZXING_EXPERIMENTAL_API |
