diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-12-24 01:12:40 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-12-24 01:12:40 +0000 |
| commit | dc87445987c00b85a44b6372e43894067fae44b3 (patch) | |
| tree | cddc35f1117f5bcb403b31d674791e6a453765ab /src/lib/image.cc | |
| parent | e194f0003b60b2607da0822485c56cd8267e78dc (diff) | |
Merge 1.0 and some subtitling fixes.
Diffstat (limited to 'src/lib/image.cc')
| -rw-r--r-- | src/lib/image.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index 18ddbc98d..5b5491101 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -376,8 +376,11 @@ Image::make_black () void Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) { - /* Only implemented for RGBA onto RGB24 so far */ - assert (_pixel_format == PIX_FMT_RGB24 && other->pixel_format() == PIX_FMT_RGBA); + /* Only implemented for RGBA onto BGRA so far */ + assert (_pixel_format == PIX_FMT_BGRA && other->pixel_format() == PIX_FMT_RGBA); + + int const this_bpp = 4; + int const other_bpp = 4; int start_tx = position.x; int start_ox = 0; @@ -396,15 +399,15 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) } for (int ty = start_ty, oy = start_oy; ty < size().height && oy < other->size().height; ++ty, ++oy) { - uint8_t* tp = data()[0] + ty * stride()[0] + position.x * 3; + uint8_t* tp = data()[0] + ty * stride()[0] + position.x * this_bpp; 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] = (tp[0] * (1 - alpha)) + op[0] * alpha; tp[1] = (tp[1] * (1 - alpha)) + op[1] * alpha; tp[2] = (tp[2] * (1 - alpha)) + op[2] * alpha; - tp += 3; - op += 4; + tp += this_bpp; + op += other_bpp; } } } |
