MCPcopy Create free account
hub / github.com/devilsen/CZXing / encode

Method encode

czxing/src/main/cpp/zxing/src/datamatrix/DMWriter.cpp:82–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82BitMatrix
83Writer::encode(const std::wstring& contents, int width, int height) const
84{
85 if (contents.empty()) {
86 throw std::invalid_argument("Found empty contents");
87 }
88
89 if (width < 0 || height < 0) {
90 throw std::invalid_argument("Requested dimensions are invalid");
91 }
92
93 //1. step: Data encodation
94 auto encoded = Encode(contents, _shapeHint, _minWidth, _minHeight, _maxWidth, _maxHeight);
95 const SymbolInfo* symbolInfo = SymbolInfo::Lookup(Size(encoded), _shapeHint, _minWidth, _minHeight, _maxWidth, _maxHeight);
96 if (symbolInfo == nullptr) {
97 throw std::invalid_argument("Can't find a symbol arrangement that matches the message. Data codewords: " + std::to_string(encoded.size()));
98 }
99
100 //2. step: ECC generation
101 EncodeECC200(encoded, *symbolInfo);
102
103 //3. step: Module placement in Matrix
104 BitMatrix symbolData = BitMatrixFromCodewords(encoded, symbolInfo->symbolDataWidth(), symbolInfo->symbolDataHeight());
105
106 //4. step: low-level encoding
107 BitMatrix result = EncodeLowLevel(symbolData, *symbolInfo);
108
109 //5. step: scale-up to requested size, minimum required quiet zone is 1
110 return Inflate(std::move(result), width, height, _quietZone);
111}
112
113BitMatrix Writer::encode(const std::string& contents, int width, int height) const
114{

Callers

nothing calls this directly

Calls 12

EncodeECC200Function · 0.85
BitMatrixFromCodewordsFunction · 0.85
InflateFunction · 0.85
moveFunction · 0.85
symbolDataWidthMethod · 0.80
symbolDataHeightMethod · 0.80
EncodeFunction · 0.70
EncodeLowLevelFunction · 0.70
SizeFunction · 0.50
FromUtf8Function · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected