AGS: Fix fully transparent savegame screenshots

If On A Winter's Night, Four Travelers was such as game that
generated fully transparent screenshots. I am not completely
sure why it happens, and the easiest solution was to reset
the alpha byte to 0xff.
This commit is contained in:
Thierry Crozat 2021-03-13 03:24:22 +00:00
parent 4945526219
commit 6816c62822
3 changed files with 17 additions and 0 deletions

View File

@ -922,6 +922,7 @@ void create_savegame_screenshot(Bitmap *&screenShot) {
quit("!Invalid game.screenshot_width/height, must be from 16x16 to screen res");
screenShot = CopyScreenIntoBitmap(usewid, usehit);
screenShot->GetAllegroBitmap()->makeOpaque();
// Restore original screen
_G(debug_flags) = old_flags;

View File

@ -51,6 +51,20 @@ int BITMAP::getpixel(int x, int y) const {
return *(const uint32 *)pixel;
}
void BITMAP::makeOpaque() {
if (format.aBits() == 0)
return;
assert(format.bytesPerPixel == 4);
uint32 alphaMask = format.ARGBToColor(0xff, 0, 0, 0);
unsigned char *pixels = getPixels();
for (int y = 0 ; y < h ; ++y, pixels += pitch) {
uint32 *data = (uint32*)pixels;
for (int x = 0 ; x < w ; ++x, ++data)
(*data) |= alphaMask;
}
}
void BITMAP::circlefill(int x, int y, int radius, int color) {
int cx = 0;
int cy = radius;

View File

@ -71,6 +71,8 @@ public:
_owner->clear();
}
void makeOpaque();
/**
* Draws a solid filled in circle
*/