diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-01-11 02:58:18 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-01-11 02:58:18 +0000 |
| commit | 31e0975bc7ca1c724cc630771edf396421ebf888 (patch) | |
| tree | 9f98143fdd758a47bd4fd627a132de4b221d5f9f /src/lib | |
| parent | fe26b2446708f5a9b71d7fe83ee445eedcced392 (diff) | |
Alpha blending fix from 1.x.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/image.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index ffe9f3e0b..d16de5e55 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -389,9 +389,9 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) uint8_t* op = other->data()[0] + oy * other->stride()[0]; for (int tx = start_tx, ox = start_ox; tx < size().width && ox < other->size().width; ++tx, ++ox) { float const alpha = float (op[3]) / 255; - tp[0] = op[0] + (tp[0] * (1 - alpha)); - tp[1] = op[1] + (tp[1] * (1 - alpha)); - tp[2] = op[2] + (tp[2] * (1 - alpha)); + tp[0] = op[0] * alpha + tp[0] * (1 - alpha); + tp[1] = op[1] * alpha + tp[1] * (1 - alpha); + tp[2] = op[2] * alpha + tp[2] * (1 - alpha); tp += this_bpp; op += other_bpp; @@ -408,10 +408,10 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) uint8_t* op = other->data()[0] + oy * other->stride()[0]; for (int tx = start_tx, ox = start_ox; tx < size().width && ox < other->size().width; ++tx, ++ox) { float const alpha = float (op[3]) / 255; - tp[0] = op[0] + (tp[0] * (1 - alpha)); - tp[1] = op[1] + (tp[1] * (1 - alpha)); - tp[2] = op[2] + (tp[2] * (1 - alpha)); - tp[3] = op[3] + (tp[3] * (1 - alpha)); + tp[0] = op[0] * alpha + tp[0] * (1 - alpha); + tp[1] = op[1] * alpha + tp[1] * (1 - alpha); + tp[2] = op[2] * alpha + tp[2] * (1 - alpha); + tp[3] = op[3] * alpha + tp[3] * (1 - alpha); tp += this_bpp; op += other_bpp; @@ -428,9 +428,9 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) for (int tx = start_tx, ox = start_ox; tx < size().width && ox < other->size().width; ++tx, ++ox) { float const alpha = float (op[3]) / 255; /* Blend high bytes */ - tp[1] = op[0] + (tp[1] * (1 - alpha)); - tp[3] = op[1] + (tp[3] * (1 - alpha)); - tp[5] = op[2] + (tp[5] * (1 - alpha)); + tp[1] = op[0] * alpha + tp[1] * (1 - alpha); + tp[3] = op[1] * alpha + tp[3] * (1 - alpha); + tp[5] = op[2] * alpha + tp[5] * (1 - alpha); tp += this_bpp; op += other_bpp; |
