MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / boxBlurVertical

Function boxBlurVertical

app/src/UI/Widgets/PainterContext.cpp:1745–1771  ·  view source on GitHub ↗

* @brief Vertical pass of a box-blur with the given radius. */

Source from the content-addressed store, hash-verified

1743 * @brief Vertical pass of a box-blur with the given radius.
1744 */
1745static void boxBlurVertical(const QImage& src, QImage& dst, int radius)
1746{
1747 const int w = src.width();
1748 const int h = src.height();
1749 const auto& inv = blurReciprocalTable();
1750 for (int x = 0; x < w; ++x) {
1751 for (int y = 0; y < h; ++y) {
1752 int r = 0, g = 0, b = 0, a = 0, n = 0;
1753 const int y0 = qMax(0, y - radius);
1754 const int y1 = qMin(h - 1, y + radius);
1755 for (int k = y0; k <= y1; ++k) {
1756 const QRgb px = reinterpret_cast<const QRgb*>(src.constScanLine(k))[x];
1757 r += qRed(px);
1758 g += qGreen(px);
1759 b += qBlue(px);
1760 a += qAlpha(px);
1761 ++n;
1762 }
1763 const int64_t recip = inv[n];
1764 reinterpret_cast<QRgb*>(dst.scanLine(y))[x] =
1765 qRgba(static_cast<int>((r * recip) >> kBlurReciprocalShift),
1766 static_cast<int>((g * recip) >> kBlurReciprocalShift),
1767 static_cast<int>((b * recip) >> kBlurReciprocalShift),
1768 static_cast<int>((a * recip) >> kBlurReciprocalShift));
1769 }
1770 }
1771}
1772
1773/**
1774 * @brief Three-pass separable box-blur applied in place to the given image.

Callers 1

applyBoxBlurFunction · 0.85

Calls 2

widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected