forked from zxing-cpp/zxing-cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWriteBarcode.h
More file actions
72 lines (53 loc) · 1.83 KB
/
WriteBarcode.h
File metadata and controls
72 lines (53 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright 2024 Axel Waggershauser
*/
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "Barcode.h"
#include "ImageView.h"
#include <memory>
namespace ZXing {
/**
* @brief Configuration options for barcode writing/generation.
*
* WriterOptions provides a fluent interface for setting various parameters
* that control how barcodes are generated.
*
* This class supports method chaining for convenient option configuration:
* ```cpp
* auto opts = WriterOptions().scale(5).addHRT(true);
* ```
*/
class WriterOptions
{
struct Data;
std::unique_ptr<Data> d;
public:
WriterOptions();
~WriterOptions();
WriterOptions(WriterOptions&&) noexcept;
WriterOptions& operator=(WriterOptions&&) noexcept;
#define ZX_PROPERTY(TYPE, NAME) \
TYPE NAME() const noexcept; \
WriterOptions& NAME(TYPE v)&; \
WriterOptions&& NAME(TYPE v)&&;
/// scale factor for rendering, ie the module size (default: 1). Passing a negative value will choose the scale
/// automatically to fit the size of the barcode to abs(scale) as close as possible.
ZX_PROPERTY(int, scale)
/// rotate the barcode by given degrees (0, 90, 180, 270)
ZX_PROPERTY(int, rotate)
/// invert the colors of the barcode
ZX_PROPERTY(bool, invert)
/// add human readable text (HRI) to the barcode
ZX_PROPERTY(bool, addHRT)
/// add quiet zones around the barcode (default: true)
ZX_PROPERTY(bool, addQuietZones)
#undef ZX_PROPERTY
};
/// Write barcode symbol to SVG
std::string WriteBarcodeToSVG(const Barcode& barcode, const WriterOptions& options = {});
/// Write barcode symbol to a utf8 string using graphical characters (e.g. '▀')
std::string WriteBarcodeToUtf8(const Barcode& barcode, const WriterOptions& options = {});
/// Write barcode symbol to Image (Bitmap)
Image WriteBarcodeToImage(const Barcode& barcode, const WriterOptions& options = {});
} // ZXing