[Scummvm-git-logs] scummvm branch-2-3 -> 76e5cc1b5e1f985095788bd95011a222e7706823

dreammaster dreammaster at scummvm.org
Tue Sep 7 05:07:50 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:
76e5cc1b5e AGS: Fixed save_bitmap for paletted games


Commit: 76e5cc1b5e1f985095788bd95011a222e7706823
    https://github.com/scummvm/scummvm/commit/76e5cc1b5e1f985095788bd95011a222e7706823
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-06T22:07:40-07:00

Commit Message:
AGS: Fixed save_bitmap for paletted games

Changed paths:
    engines/ags/shared/gfx/image.cpp


diff --git a/engines/ags/shared/gfx/image.cpp b/engines/ags/shared/gfx/image.cpp
index fafc35ee0a..b8a859d7d6 100644
--- a/engines/ags/shared/gfx/image.cpp
+++ b/engines/ags/shared/gfx/image.cpp
@@ -111,18 +111,20 @@ int save_bitmap(Common::WriteStream &out, BITMAP *bmp, const RGB *pal) {
 	Graphics::ManagedSurface surface(bmp->w, bmp->h, requiredFormat_3byte);
 
 	Graphics::ManagedSurface &src = bmp->getSurface();
-	if (bmp->format.bytesPerPixel == 1 && pal != nullptr && !src.getPalette()) {
-		// For paletted images, set up the palette as needed
-		byte palette[256 * 3];
-		for (int c = 0, i = 0 ; c < 256 ; ++c, i += 3) {
-			palette[i] = VGA_COLOR_TRANS(pal[c].r);
-			palette[i + 1] = VGA_COLOR_TRANS(pal[c].g);
-			palette[i + 2] = VGA_COLOR_TRANS(pal[c].b);
+	if (bmp->format.bytesPerPixel == 1) {
+		Graphics::ManagedSurface temp = src;
+		if (pal) {
+			byte palette[256 * 3];
+			for (int c = 0, i = 0; c < 256; ++c, i += 3) {
+				palette[i] = VGA_COLOR_TRANS(pal[c].r);
+				palette[i + 1] = VGA_COLOR_TRANS(pal[c].g);
+				palette[i + 2] = VGA_COLOR_TRANS(pal[c].b);
+			}
+			temp.setPalette(palette, 0, 256);
 		}
-		src.setPalette(palette, 0, 256);
 
-		surface.rawBlitFrom(src, Common::Rect(0, 0, src.w, src.h),
-			Common::Point(0, 0), src.getPalette());
+		surface.rawBlitFrom(temp, Common::Rect(0, 0, src.w, src.h),
+			Common::Point(0, 0), temp.getPalette());
 	} else {
 		// Copy from the source surface without alpha transparency
 		Graphics::ManagedSurface temp = src;




More information about the Scummvm-git-logs mailing list