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

Function WillFit

czxing/src/main/cpp/zxing/src/qrcode/QREncoder.cpp:254–265  ·  view source on GitHub ↗

* @return true if the number of input bits will fit in a code with the specified version and * error correction level. */

Source from the content-addressed store, hash-verified

252* error correction level.
253*/
254static bool WillFit(int numInputBits, const Version& version, ErrorCorrectionLevel ecLevel) {
255 // In the following comments, we use numbers of Version 7-H.
256 // numBytes = 196
257 int numBytes = version.totalCodewords();
258 // getNumECBytes = 130
259 auto& ecBlocks = version.ecBlocksForLevel(ecLevel);
260 int numEcBytes = ecBlocks.totalCodewords();
261 // getNumDataBytes = 196 - 130 = 66
262 int numDataBytes = numBytes - numEcBytes;
263 int totalInputBytes = (numInputBits + 7) / 8;
264 return numDataBytes >= totalInputBytes;
265}
266
267static const Version& ChooseVersion(int numInputBits, ErrorCorrectionLevel ecLevel)
268{

Callers 2

QREncoder.cppFile · 0.85
EncodeFunction · 0.85

Calls 1

totalCodewordsMethod · 0.45

Tested by

no test coverage detected