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

Function ToSVG

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

Source from the content-addressed store, hash-verified

31}
32
33std::string ToSVG(const BitMatrix& matrix)
34{
35 // see https://stackoverflow.com/questions/10789059/create-qr-code-in-vector-image/60638350#60638350
36
37 const int width = matrix.width();
38 const int height = matrix.height();
39 std::ostringstream out;
40
41 out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
42 << "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 " << width << " " << height
43 << "\" stroke=\"none\">\n"
44 << "<path d=\"";
45
46 for (int y = 0; y < height; ++y)
47 for (int x = 0; x < width; ++x)
48 if (matrix.get(x, y))
49 out << "M" << x << "," << y << "h1v1h-1z";
50
51 out << "\"/>\n</svg>";
52
53 return out.str();
54}
55
56BitMatrix ParseBitMatrix(const std::string& str, char one, bool expectSpace)
57{

Callers

nothing calls this directly

Calls 3

widthMethod · 0.45
heightMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected