7#include "barcodeutil_p.h"
8#include "code39barcode_p.h"
17 return BarCodeUtil::barSequence(
"000110100");
19 return BarCodeUtil::barSequence(
"100100001");
21 return BarCodeUtil::barSequence(
"001100001");
23 return BarCodeUtil::barSequence(
"101100000");
25 return BarCodeUtil::barSequence(
"000110001");
27 return BarCodeUtil::barSequence(
"100110000");
29 return BarCodeUtil::barSequence(
"001110000");
31 return BarCodeUtil::barSequence(
"000100101");
33 return BarCodeUtil::barSequence(
"100100100");
35 return BarCodeUtil::barSequence(
"001100100");
37 return BarCodeUtil::barSequence(
"100001001");
39 return BarCodeUtil::barSequence(
"001001001");
41 return BarCodeUtil::barSequence(
"101001000");
43 return BarCodeUtil::barSequence(
"000011001");
45 return BarCodeUtil::barSequence(
"100011000");
47 return BarCodeUtil::barSequence(
"001011000");
49 return BarCodeUtil::barSequence(
"000001101");
51 return BarCodeUtil::barSequence(
"100001100");
53 return BarCodeUtil::barSequence(
"001001100");
55 return BarCodeUtil::barSequence(
"000011100");
57 return BarCodeUtil::barSequence(
"100000011");
59 return BarCodeUtil::barSequence(
"001000011");
61 return BarCodeUtil::barSequence(
"101000010");
63 return BarCodeUtil::barSequence(
"000010011");
65 return BarCodeUtil::barSequence(
"100010010");
67 return BarCodeUtil::barSequence(
"001010010");
69 return BarCodeUtil::barSequence(
"000000111");
71 return BarCodeUtil::barSequence(
"100000110");
73 return BarCodeUtil::barSequence(
"001000110");
75 return BarCodeUtil::barSequence(
"000010110");
77 return BarCodeUtil::barSequence(
"110000001");
79 return BarCodeUtil::barSequence(
"011000001");
81 return BarCodeUtil::barSequence(
"111000000");
83 return BarCodeUtil::barSequence(
"010010001");
85 return BarCodeUtil::barSequence(
"110010000");
87 return BarCodeUtil::barSequence(
"011010000");
89 return BarCodeUtil::barSequence(
"010000101");
91 return BarCodeUtil::barSequence(
"110000100");
93 return BarCodeUtil::barSequence(
"011000100");
95 return BarCodeUtil::barSequence(
"010101000");
97 return BarCodeUtil::barSequence(
"010100010");
99 return BarCodeUtil::barSequence(
"010001010");
101 return BarCodeUtil::barSequence(
"000101010");
107Code39Barcode::Code39Barcode()
108 : AbstractBarcodePrivate(
Barcode::OneDimension)
111Code39Barcode::~Code39Barcode() =
default;
113QImage Code39Barcode::paintImage()
119 const QList<bool> endSequence = BarCodeUtil::barSequence(
"010010100");
120 barcode += endSequence;
123 const auto str = BarCodeUtil::asLatin1ByteArray(m_data);
124 for (
int i = 0; i < str.size(); i++) {
132 barcode += endSequence;
144 const int wide = barcode.
count(
true);
145 const int narrow = barcode.
count(
false);
147 const int largeWidth = 2;
149 const int smallWidth = 1;
150 Q_ASSERT(largeWidth > smallWidth);
152 const int quietZoneWidth = 10 * smallWidth;
156 line.
reserve(wide * largeWidth + narrow * smallWidth + 2 * quietZoneWidth);
157 line.
insert(0, quietZoneWidth, m_background.rgba());
158 for (
int i = 0; i < barcode.
size(); i++) {
159 const QRgb color = (((i & 1) == 0) ? m_foreground : m_background).rgba();
160 const int width = barcode.
at(i) ? largeWidth : smallWidth;
161 for (
int j = 0; j < width; j++) {
165 line.
insert(line.
size(), quietZoneWidth, m_background.rgba());
169 memcpy(ret.scanLine(0), line.
data(), line.
size() *
sizeof(QRgb));
A barcode generator for a fixed barcode format.
Provides classes and methods for generating barcodes.
QChar toUpper() const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype count() const const
iterator insert(const_iterator before, parameter_type value)
void reserve(qsizetype size)
qsizetype size() const const