CVB++ 14.1
pdf417.hpp
1#pragma once
2
3#include "reader_2d_config_base.hpp"
4
5namespace Cvb
6{
7 CVB_BEGIN_INLINE_NS
8
9 namespace Barcode
10 {
11 using namespace Internal;
12
14
17 {
18public:
19
21
27 {
28 if(levels_ != levels)
29 SetDirty();
30 levels_ = levels;
31 }
32
34
40 {
41 return levels_;
42 };
43
45
50 void SetMinRows(int minRows)
51 {
52 if(minRows < MinRowsLimit_ ||
53 minRows > maxRows_)
54 throw std::runtime_error("MinRows out of range");
55 if(minRows_ != minRows)
56 SetDirty();
57 minRows_ = static_cast<short>(minRows);
58 }
59
61
66 int MinRows() const
67 {
68 return static_cast<int>(minRows_);
69 };
70
72
77 void SetMaxRows(int maxRows)
78 {
79 if(maxRows < minRows_ ||
80 maxRows > MaxRowsLimit_)
81 throw std::runtime_error("MaxRows out of range");
82 if(maxRows_ != maxRows)
83 SetDirty();
84 maxRows_ = static_cast<short>(maxRows);
85 }
86
88
93 int MaxRows() const
94 {
95 return static_cast<int>(maxRows_);
96 };
97
98
100
105 void SetMinColumns(int minColumns)
106 {
107 if(minColumns < MinColumnsLimit_ ||
108 minColumns > maxColumns_)
109 throw std::runtime_error("MinColumns out of range");
110 if(minColumns_ != minColumns)
111 SetDirty();
112 minColumns_ = static_cast<short>(minColumns);
113 }
114
116
121 int MinColumns() const
122 {
123 return static_cast<int>(minColumns_);
124 };
125
127
132 void SetMaxColumns(int maxColumns)
133 {
134 if(maxColumns< minColumns_ ||
135 maxColumns > MaxColumnsLimit_)
136 throw std::runtime_error("MaxColumns out of range");
137 if(maxColumns_ != maxColumns)
138 SetDirty();
139 maxColumns_ = static_cast<short>(maxColumns);
140 }
141
143
148 int MaxColumns() const
149 {
150 return static_cast<int>(maxColumns_);
151 };
152
153
154
155 protected:
156 Pdf417Levels levels_;
157 short minRows_;
158 short maxRows_;
159 short minColumns_;
160 short maxColumns_;
161
162 const short MinRowsLimit_ = 3;
163 const short MaxRowsLimit_ = 90;
164
165 const short MinColumnsLimit_ = 1;
166 const short MaxColumnsLimit_ = 30;
167
168
169 public:
170 virtual Symbology Type() const override { return Symbology::Pdf417; };
171
173
179 static std::unique_ptr<Pdf417> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
180 {
181 auto pConfig = std::unique_ptr<Pdf417>(new Pdf417());
182 isActiveOut = pConfig->ReadFromHandle(guard);
183 return pConfig;
184 }
185
186 protected:
187 virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
188 {
189 unsigned short tmpLevels;
190 CVB_CALL_CAPI(CvcBcGetPDF417(reinterpret_cast<std::intptr_t>(guard.Handle()),
191 &tmpLevels,
192 &minRows_,
193 &maxRows_,
194 &minColumns_,
195 &maxColumns_,
196 mirrored_.Ptr(),
197 inverse_.Ptr()));
198 levels_ = static_cast<Pdf417Levels>(tmpLevels);
199 return tmpLevels != 0;
200 }
201
202 virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
203 {
204 if (!active)
205 levels_ = static_cast<Pdf417Levels>(0);
206 Internal::DoResCall([&]()
207 {
208 return CVB_CALL_CAPI(CvcBcSetPDF417(reinterpret_cast<std::intptr_t>(guard.Handle()),
209 static_cast<unsigned short>(levels_),
210 minRows_,
211 maxRows_,
212 minColumns_,
213 maxColumns_,
214 mirrored_,
215 inverse_));
216 });
217 }
218 protected:
219 Pdf417()
220 : Reader2DConfigBase()
221 {
222 }
223
224 };
225
226 using Pdf417Ptr = std::shared_ptr<Pdf417>;
227 }
228
229 CVB_END_INLINE_NS
230}
Configuration to access parameters of Reader2DConfigBase.
Definition: reader_2d_config_base.hpp:19
Configuration to access parameters of Pdf417.
Definition: pdf417.hpp:17
void SetMaxRows(int maxRows)
Sets the maximum number of data rows.
Definition: pdf417.hpp:77
Pdf417Levels Levels() const
Returns the bit field which specifies the permitted error correction level.
Definition: pdf417.hpp:39
static std::unique_ptr< Pdf417 > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: pdf417.hpp:179
int MaxColumns() const
Returns the maximum number of data columns.
Definition: pdf417.hpp:148
void SetLevels(Pdf417Levels levels)
Bit field which specifies the permitted error correction level.
Definition: pdf417.hpp:26
int MinColumns() const
Returns the minimum number of data columns.
Definition: pdf417.hpp:121
void SetMinRows(int minRows)
Sets the minimum number of data rows.
Definition: pdf417.hpp:50
void SetMinColumns(int minColumns)
Sets the minimum number of data columns.
Definition: pdf417.hpp:105
int MaxRows() const
Returns the maximum number of data rows.
Definition: pdf417.hpp:93
int MinRows() const
Returns the minimum number of data rows.
Definition: pdf417.hpp:66
void SetMaxColumns(int maxColumns)
Sets the maximum number of data columns.
Definition: pdf417.hpp:132
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ Pdf417
PDF417 Matrix Code.
Pdf417Levels
Available PDF417 levels.
Definition: barcode.hpp:371
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24