[Scummvm-git-logs] scummvm master -> 2c1741e5c6ee61575988d74e850802c4f1abae41

lephilousophe noreply at scummvm.org
Sun Apr 2 09:38:22 UTC 2023


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:
2c1741e5c6 GRAPHICS: Preventively remove alpha channel for screenshots


Commit: 2c1741e5c6ee61575988d74e850802c4f1abae41
    https://github.com/scummvm/scummvm/commit/2c1741e5c6ee61575988d74e850802c4f1abae41
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-04-02T11:38:18+02:00

Commit Message:
GRAPHICS: Preventively remove alpha channel for screenshots

Preserving the alpha channel for screenshots
is not really needed and causes problems in
the AGS engine (and possibily other engines)

Changed paths:
    backends/graphics/opengl/opengl-graphics.cpp


diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index 718379dea5a..ddca6f346d1 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1728,14 +1728,10 @@ bool OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const
 	const uint width  = _windowWidth;
 	const uint height = _windowHeight;
 
-	// A line of a BMP image must have a size divisible by 4.
-	// We calculate the padding bytes needed here.
-	// Since we use a 4 byte per pixel mode, we can use 0 here, since it is
-	// equal to (4 - (width * 4)) % 4. (4 - (width * Bpp)) % 4, is the usual
-	// way of computing the padding bytes required).
-	// GL_PACK_ALIGNMENT is 4, so this line padding is required for PNG too
-	const uint linePaddingSize = 0;
-	const uint lineSize        = width * 4 + linePaddingSize;
+	// GL_PACK_ALIGNMENT is 4 so each row must be aligned to 4 bytes boundary
+	// A line of a BMP image must also have a size divisible by 4.
+	// Calculate lineSize as the next multiple of 4 after the real line size
+	const uint lineSize        = (width * 3 + 3) & ~3;
 
 	Common::DumpFile out;
 	if (!out.open(filename)) {
@@ -1744,12 +1740,12 @@ bool OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const
 
 	Common::Array<uint8> pixels;
 	pixels.resize(lineSize * height);
-	GL_CALL(glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, &pixels.front()));
+	GL_CALL(glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, &pixels.front()));
 
 #ifdef SCUMM_LITTLE_ENDIAN
-	const Graphics::PixelFormat format(4, 8, 8, 8, 8, 0, 8, 16, 24);
+	const Graphics::PixelFormat format(3, 8, 8, 8, 0, 0, 8, 16, 0);
 #else
-	const Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
+	const Graphics::PixelFormat format(3, 8, 8, 8, 0, 16, 8, 0, 0);
 #endif
 	Graphics::Surface data;
 	data.init(width, height, lineSize, &pixels.front(), format);




More information about the Scummvm-git-logs mailing list