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

Function ParseBitMatrix

czxing/src/main/cpp/zxing/src/BitMatrixIO.cpp:56–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56BitMatrix ParseBitMatrix(const std::string& str, char one, bool expectSpace)
57{
58 auto lineLength = str.find('\n');
59 if (lineLength == std::string::npos)
60 return {};
61
62 int strStride = expectSpace ? 2 : 1;
63 int height = narrow_cast<int>(str.length() / (lineLength + 1));
64 int width = narrow_cast<int>(lineLength / strStride);
65 BitMatrix mat(width, height);
66 for (int y = 0; y < height; ++y) {
67 size_t offset = y * (lineLength + 1);
68 for (int x = 0; x < width; ++x, offset += strStride) {
69 if (str[offset] == one)
70 mat.set(x, y);
71 }
72 }
73 return mat;
74}
75
76void SaveAsPBM(const BitMatrix& matrix, const std::string filename, int quietZone)
77{

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
lengthMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected