Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix distortion on watermark text
Change-Id: Id1bda715723e717d6f0893dbc1aef937014076e3
Signed-off-by: mert <mert.tumer@collabora.com>
  • Loading branch information
mert authored and merttumer committed Nov 15, 2020
1 parent 7a02a8c commit 8422d2d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kit/Watermark.hpp
Expand Up @@ -55,21 +55,21 @@ class Watermark final
offsetX += (tileWidth - maxX) / 2;
offsetY += (tileHeight - maxY) / 2;

alphaBlend(*pixmap, _width, _height, offsetX, offsetY, tilePixmap, tilesPixmapWidth, tilesPixmapHeight);
alphaBlend(*pixmap, _width, _height, offsetX, offsetY, tilePixmap, tilesPixmapWidth, tilesPixmapHeight, false);
}
}

private:
/// Alpha blend pixels from 'from' over the 'to'.
void alphaBlend(const std::vector<unsigned char>& from, int from_width, int from_height, int from_offset_x, int from_offset_y,
unsigned char* to, int to_width, int to_height)
unsigned char* to, int to_width, int to_height, const bool isFontBlending)
{
for (int to_y = from_offset_y, from_y = 0; (to_y < to_height) && (from_y < from_height) ; ++to_y, ++from_y)
for (int to_x = from_offset_x, from_x = 0; (to_x < to_width) && (from_x < from_width); ++to_x, ++from_x)
{
unsigned char* t = to + 4 * (to_y * to_width + to_x);

if (t[3] != 255)
if (!isFontBlending && t[3] != 255)
continue;

double dst_r = t[0];
Expand Down Expand Up @@ -164,7 +164,7 @@ class Watermark final
}

// Now copy the (black) text over the (white) blur
alphaBlend(text, _width, _height, 0, 0, _pixmap.data(), _width, _height);
alphaBlend(text, _width, _height, 0, 0, _pixmap.data(), _width, _height, true);

// Make the resulting pixmap semi-transparent
for (unsigned char* p = _pixmap.data(); p < _pixmap.data() + pixel_count; p++)
Expand Down

0 comments on commit 8422d2d

Please sign in to comment.