7#include "barcodeutil_p.h"
8#include "code93barcode_p.h"
18 return BarCodeUtil::barSequence(
"100010100");
20 return BarCodeUtil::barSequence(
"101001000");
22 return BarCodeUtil::barSequence(
"101000100");
24 return BarCodeUtil::barSequence(
"101000010");
26 return BarCodeUtil::barSequence(
"100101000");
28 return BarCodeUtil::barSequence(
"100100100");
30 return BarCodeUtil::barSequence(
"100100010");
32 return BarCodeUtil::barSequence(
"101010000");
34 return BarCodeUtil::barSequence(
"100010010");
36 return BarCodeUtil::barSequence(
"100001010");
38 return BarCodeUtil::barSequence(
"110101000");
40 return BarCodeUtil::barSequence(
"110100100");
42 return BarCodeUtil::barSequence(
"110100010");
44 return BarCodeUtil::barSequence(
"110010100");
46 return BarCodeUtil::barSequence(
"110010010");
48 return BarCodeUtil::barSequence(
"110001010");
50 return BarCodeUtil::barSequence(
"101101000");
52 return BarCodeUtil::barSequence(
"101100100");
54 return BarCodeUtil::barSequence(
"101100010");
56 return BarCodeUtil::barSequence(
"100110100");
58 return BarCodeUtil::barSequence(
"100011010");
60 return BarCodeUtil::barSequence(
"101011000");
62 return BarCodeUtil::barSequence(
"101001100");
64 return BarCodeUtil::barSequence(
"101000110");
66 return BarCodeUtil::barSequence(
"100101100");
68 return BarCodeUtil::barSequence(
"100010110");
70 return BarCodeUtil::barSequence(
"110110100");
72 return BarCodeUtil::barSequence(
"110110010");
74 return BarCodeUtil::barSequence(
"110101100");
76 return BarCodeUtil::barSequence(
"110100110");
78 return BarCodeUtil::barSequence(
"110010110");
80 return BarCodeUtil::barSequence(
"110011010");
82 return BarCodeUtil::barSequence(
"101101100");
84 return BarCodeUtil::barSequence(
"101100110");
86 return BarCodeUtil::barSequence(
"100110110");
88 return BarCodeUtil::barSequence(
"100111010");
90 return BarCodeUtil::barSequence(
"100101110");
92 return BarCodeUtil::barSequence(
"111010100");
94 return BarCodeUtil::barSequence(
"111010010");
96 return BarCodeUtil::barSequence(
"111001010");
98 return BarCodeUtil::barSequence(
"101101110");
100 return BarCodeUtil::barSequence(
"101110110");
102 return BarCodeUtil::barSequence(
"110101110");
104 return BarCodeUtil::barSequence(
"100100110");
106 return BarCodeUtil::barSequence(
"111011010");
108 return BarCodeUtil::barSequence(
"111010110");
110 return BarCodeUtil::barSequence(
"100110010");
112 return BarCodeUtil::barSequence(
"101011110");
115 qWarning(
"Code93Barcode::sequenceForID called with unknown ID");
599static int checksum(
const QList<int> &codes,
int wrap)
602 for (
int i = 0; i < codes.
size(); i++) {
604 const int weight = (codes.
size() - i - 1) % wrap + 1;
605 check += codes.
at(i) * weight;
610Code93Barcode::Code93Barcode()
611 : AbstractBarcodePrivate(
Barcode::OneDimension)
614Code93Barcode::~Code93Barcode() =
default;
616QImage Code93Barcode::paintImage()
623 const auto str = BarCodeUtil::asLatin1ByteArray(m_data);
624 for (
int i = 0; i < str.size(); i++) {
625 codes += codesForChar(str.at(i));
629 codes.
append(checksum(codes, 20));
630 codes.
append(checksum(codes, 15));
635 barcode += endSequence;
637 for (
int i = 0; i < codes.
size(); i++) {
638 barcode += sequenceForID(codes.
at(i));
641 barcode += endSequence;
646 const int barWidth = 1;
647 const int quietZoneWidth = 10 * barWidth;
651 line.
reserve(barWidth * barcode.
size() + 2 * quietZoneWidth);
652 line.
insert(0, quietZoneWidth, m_background.rgba());
653 for (
int i = 0; i < barcode.
size(); i++) {
654 const QRgb color = (barcode.
at(i) ? m_foreground : m_background).rgba();
655 for (
int j = 0; j < barWidth; j++) {
659 line.
insert(line.
size(), quietZoneWidth, m_background.rgba());
663 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.
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
iterator insert(const_iterator before, parameter_type value)
void reserve(qsizetype size)
qsizetype size() const const