[Scummvm-git-logs] scummvm master -> 180d364ebe5c2e628244f0807dc2ca4ebf087a6d
criezy
criezy at scummvm.org
Mon Mar 15 21:03:30 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
180d364ebe AGS: Fix allegro mask color
Commit: 180d364ebe5c2e628244f0807dc2ca4ebf087a6d
https://github.com/scummvm/scummvm/commit/180d364ebe5c2e628244f0807dc2ca4ebf087a6d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-03-15T21:03:12Z
Commit Message:
AGS: Fix allegro mask color
In allegro the mask color has alpha set to 0. We were setting it
to 0xff and that caused comparaison of colors with mask to fail
in some places in the engine, for example causing the check of
whether a given position is on a sprite to fail (it was returning
true for any position inside the sprite bitmap, even if on a
transparent pixel).
See my_getpixel(Bitmap *, int x, int y) in character.cpp that
strips the alpha from the color just for that purpose (it is
called from is_pos_in_sprite()) where the pixel is compared to
the mask color..
Changed paths:
engines/ags/lib/allegro/gfx.cpp
engines/ags/lib/allegro/surface.h
diff --git a/engines/ags/lib/allegro/gfx.cpp b/engines/ags/lib/allegro/gfx.cpp
index b497fac2aa..9bb2bb5488 100644
--- a/engines/ags/lib/allegro/gfx.cpp
+++ b/engines/ags/lib/allegro/gfx.cpp
@@ -33,11 +33,6 @@ namespace AGS3 {
int color_conversion;
-// For Allegro, paletted sprites always use index 0 as the transparent color,
-// and for higher resolution formats uses bright pink RGB 255, 0, 255
-#define TRANSPARENT_COLOR(BITMAP) ((BITMAP).format.bytesPerPixel == 1 ? 0 : \
- (BITMAP).format.RGBToColor(255, 0, 255))
-
/*-------------------------------------------------------------------*/
void set_color_conversion(int mode) {
@@ -98,7 +93,13 @@ int bitmap_color_depth(BITMAP *bmp) {
}
int bitmap_mask_color(BITMAP *bmp) {
- return TRANSPARENT_COLOR(*bmp);
+ // For paletted sprites this is 0.
+ // For other color depths this is bright pink (RGB 255, 0, 255).
+ // The alpha chanel should be 0.
+ //if (bmp-format.bytesPerPixel == 1)
+ // return 0;
+ //return bmp->format.AGRBToColor(0, 255, 0, 255);
+ return bmp->getTransparentColor();
}
void blit(const BITMAP *src, BITMAP *dest, int src_x, int src_y, int dst_x, int dst_y, int width, int height) {
diff --git a/engines/ags/lib/allegro/surface.h b/engines/ags/lib/allegro/surface.h
index 1a4362f958..a855857608 100644
--- a/engines/ags/lib/allegro/surface.h
+++ b/engines/ags/lib/allegro/surface.h
@@ -62,7 +62,12 @@ public:
}
uint getTransparentColor() const {
- return _owner->getTransparentColor();
+ // See allegro bitmap_mask_color
+ // For paletted sprites this is 0.
+ // For other color depths this is bright pink (RGB 255, 0, 255) with alpha set to 0.
+ if (format.bytesPerPixel == 1)
+ return 0;
+ return format.ARGBToColor(0, 255, 0, 255);
}
int getpixel(int x, int y) const;
More information about the Scummvm-git-logs
mailing list