Changeset View
Changeset View
Standalone View
Standalone View
src/lib/code128barcode.cpp
Show All 22 Lines | 1 | /* | |||
---|---|---|---|---|---|
23 | OTHER DEALINGS IN THE SOFTWARE. | 23 | OTHER DEALINGS IN THE SOFTWARE. | ||
24 | 24 | | |||
25 | */ | 25 | */ | ||
26 | 26 | | |||
27 | #include "code128barcode.h" | 27 | #include "code128barcode.h" | ||
28 | #include "bitvector_p.h" | 28 | #include "bitvector_p.h" | ||
29 | #include "prison_debug.h" | 29 | #include "prison_debug.h" | ||
30 | 30 | | |||
31 | using namespace Prison; | | |||
32 | | ||||
33 | #include <QImage> | 31 | #include <QImage> | ||
34 | #include <QPainter> | 32 | #include <QPainter> | ||
35 | 33 | | |||
34 | using namespace Prison; | ||||
35 | | ||||
36 | enum { | 36 | enum { | ||
37 | SymbolSize = 11, | 37 | SymbolSize = 11, | ||
38 | StopPatternSize = 13, | 38 | StopPatternSize = 13, | ||
39 | StopPattern = 108, | 39 | StopPattern = 108, | ||
40 | QuietZone = 10, | 40 | QuietZone = 10, | ||
41 | }; | 41 | }; | ||
42 | 42 | | |||
43 | enum CodeSet : uint8_t { | 43 | enum CodeSet : uint8_t { | ||
Show All 30 Lines | 65 | { | |||
74 | if (moduleSize < 1) // too small for this | 74 | if (moduleSize < 1) // too small for this | ||
75 | return {}; | 75 | return {}; | ||
76 | 76 | | |||
77 | QImage img(moduleSize * width, size.height(), QImage::Format_ARGB32); | 77 | QImage img(moduleSize * width, size.height(), QImage::Format_ARGB32); | ||
78 | img.fill(backgroundColor()); | 78 | img.fill(backgroundColor()); | ||
79 | QPainter p(&img); | 79 | QPainter p(&img); | ||
80 | for (int i = 0; i < bits.size(); ++i) { | 80 | for (int i = 0; i < bits.size(); ++i) { | ||
81 | if (bits.at(i)) | 81 | if (bits.at(i)) | ||
82 | p.fillRect((QuietZone + i) * moduleSize, 0, moduleSize, img.height(), foregroundColor()); | 82 | p.fillRect(QRectF((QuietZone + i) * moduleSize, 0, moduleSize, img.height()), foregroundColor()); | ||
83 | } | 83 | } | ||
84 | 84 | | |||
85 | return img; | 85 | return img; | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | // Code 128 symbol table | 88 | // Code 128 symbol table | ||
89 | // ### this is the perfect use-case for binary literals (as the binary pattern | 89 | // ### this is the perfect use-case for binary literals (as the binary pattern | ||
90 | // corresponds to the line pattern), adjust this once KF5 moves to C++14 | 90 | // corresponds to the line pattern), adjust this once KF5 moves to C++14 | ||
▲ Show 20 Lines • Show All 266 Lines • Show Last 20 Lines |