MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / fuzzyComparePixel

Function fuzzyComparePixel

test/symbol_t.cpp:70–95  ·  view source on GitHub ↗

* Tests if any pixel in the image region given by x0, y0, x1, y1 * approximately matches the expected value. */

Source from the content-addressed store, hash-verified

68 * approximately matches the expected value.
69 */
70bool fuzzyComparePixel(const QImage& image, int x0, int y0, int x1, int y1, const quint32 expected)
71{
72 for (int y = y0; y < y1; ++y)
73 {
74 const auto* scanline = reinterpret_cast<const quint32*>(image.scanLine(y));
75 for (int x = x0; x < x1; ++x)
76 {
77 if (scanline[x] == expected)
78 return true;
79 }
80 }
81 for (int y = y0; y < y1; ++y)
82 {
83 const auto* scanline = reinterpret_cast<const quint32*>(image.scanLine(y));
84 for (int x = x0; x < x1; ++x)
85 {
86 const auto actual = scanline[x];
87 if (qAbs(qRed(actual) - qRed(expected)) <= 1
88 && qAbs(qGreen(actual) - qGreen(expected)) <= 1
89 && qAbs(qBlue(actual) - qBlue(expected)) <= 1
90 && qAbs(qAlpha(actual) - qAlpha(expected)) <= 1)
91 return true;
92 }
93 }
94 return false;
95}
96
97
98/**

Callers 1

fuzzyDifferenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected