aboutsummaryrefslogtreecommitdiff
path: root/graphics/transparent_surface.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2019-01-01 23:06:35 +0100
committerEugene Sandulenko2019-11-13 22:07:08 +0100
commitb45cadb0654ce47dea0d24046110820b9ce8ae99 (patch)
treea75f34f617365c81abd3cf690a387ea63eba739f /graphics/transparent_surface.cpp
parent8259a8aa333bb226339aa0defb2db59e7412de2d (diff)
downloadscummvm-rg350-b45cadb0654ce47dea0d24046110820b9ce8ae99.tar.gz
scummvm-rg350-b45cadb0654ce47dea0d24046110820b9ce8ae99.tar.bz2
scummvm-rg350-b45cadb0654ce47dea0d24046110820b9ce8ae99.zip
GRAPHICS: Enhanced setAlpha method
Diffstat (limited to 'graphics/transparent_surface.cpp')
-rw-r--r--graphics/transparent_surface.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/graphics/transparent_surface.cpp b/graphics/transparent_surface.cpp
index a24f7198aa..eb8d3fe5ce 100644
--- a/graphics/transparent_surface.cpp
+++ b/graphics/transparent_surface.cpp
@@ -719,15 +719,17 @@ void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool
/**
* Sets alpha channel for all pixels to specified value
* @param alpha value of the alpha channel to set
+ * @param skipTransparent if set to true, then do not touch pixels with alpha=0
*/
-void TransparentSurface::setAlpha(uint8 alpha) {
+void TransparentSurface::setAlpha(uint8 alpha, bool skipTransparent) {
assert(format.bytesPerPixel == 4);
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
uint32 pix = ((uint32 *)pixels)[i * w + j];
uint8 r, g, b, a;
format.colorToARGB(pix, a, r, g, b);
- a = alpha;
+ if (!skipTransparent || a)
+ a = alpha;
((uint32 *)pixels)[i * w + j] = format.ARGBToColor(a, r, g, b);
}
}