[Scummvm-git-logs] scummvm branch-2-3 -> 2946efb0500af22b38a29cb88760928b5c40c5e0
dreammaster
dreammaster at scummvm.org
Thu Sep 2 05:18:59 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:
2946efb050 AGS: Fix writing 32-bit images that don't have transparencies set
Commit: 2946efb0500af22b38a29cb88760928b5c40c5e0
https://github.com/scummvm/scummvm/commit/2946efb0500af22b38a29cb88760928b5c40c5e0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-01T22:18:47-07:00
Commit Message:
AGS: Fix writing 32-bit images that don't have transparencies set
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 8d738f8296..fafc35ee0a 100644
--- a/engines/ags/shared/gfx/image.cpp
+++ b/engines/ags/shared/gfx/image.cpp
@@ -108,10 +108,11 @@ int save_bitmap(Common::WriteStream &out, BITMAP *bmp, const RGB *pal) {
#else
const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
#endif
+ Graphics::ManagedSurface surface(bmp->w, bmp->h, requiredFormat_3byte);
Graphics::ManagedSurface &src = bmp->getSurface();
- if (bmp->format.bytesPerPixel == 1 && pal != nullptr) {
- // We don't use the ManagedSurface palette in-game, so it is not defined yet.
+ 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);
@@ -119,11 +120,19 @@ int save_bitmap(Common::WriteStream &out, BITMAP *bmp, const RGB *pal) {
palette[i + 2] = VGA_COLOR_TRANS(pal[c].b);
}
src.setPalette(palette, 0, 256);
+
+ surface.rawBlitFrom(src, Common::Rect(0, 0, src.w, src.h),
+ Common::Point(0, 0), src.getPalette());
+ } else {
+ // Copy from the source surface without alpha transparency
+ Graphics::ManagedSurface temp = src;
+ temp.format.aLoss = 8;
+
+ surface.rawBlitFrom(temp, Common::Rect(0, 0, src.w, src.h),
+ Common::Point(0, 0), nullptr);
}
- Graphics::ManagedSurface surface(bmp->w, bmp->h, requiredFormat_3byte);
- surface.rawBlitFrom(bmp->getSurface(), Common::Rect(0, 0, src.w, src.h),
- Common::Point(0, 0), src.getPalette());
+ // Write out the bitmap
int dstPitch = surface.w * 3;
int extraDataLength = (dstPitch % 4) ? 4 - (dstPitch % 4) : 0;
int padding = 0;
More information about the Scummvm-git-logs
mailing list