| 80 | } |
| 81 | |
| 82 | BitMatrix |
| 83 | Writer::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 | |
| 113 | BitMatrix Writer::encode(const std::string& contents, int width, int height) const |
| 114 | { |
nothing calls this directly
no test coverage detected