[Scummvm-git-logs] scummvm master -> 62851abfa11d82ef33cef0286c9b7eae8f0aa438
bluegr
noreply at scummvm.org
Thu Jun 19 11:17:55 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
48854f0ace GRAPHICS: Add helper functions for creating RGB24 and BGR24 formats
62851abfa1 GRAPHICS: Add helper functions for creating RGBA32 and BGRA32 formats
Commit: 48854f0acea7685b976313626296a3325b3b323a
https://github.com/scummvm/scummvm/commit/48854f0acea7685b976313626296a3325b3b323a
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T14:17:51+03:00
Commit Message:
GRAPHICS: Add helper functions for creating RGB24 and BGR24 formats
Changed paths:
engines/ags/shared/gfx/image.cpp
engines/freescape/gfx.cpp
engines/freescape/gfx.h
engines/grim/material.cpp
engines/playground3d/playground3d.cpp
engines/stark/formats/dds.cpp
engines/ultima/ultima4/gfx/imageloader.cpp
graphics/opengl/texture.h
graphics/pixelformat.h
graphics/tinygl/init.cpp
image/bmp.cpp
image/codecs/bmp_raw.cpp
image/jpeg.cpp
image/png.cpp
test/image/blending.h
diff --git a/engines/ags/shared/gfx/image.cpp b/engines/ags/shared/gfx/image.cpp
index 4cd8d8a99c6..8d1a5f1bf29 100644
--- a/engines/ags/shared/gfx/image.cpp
+++ b/engines/ags/shared/gfx/image.cpp
@@ -133,11 +133,7 @@ BITMAP *load_bitmap(PACKFILE *pf, color *pal) {
}
int save_bitmap(Common::WriteStream &out, BITMAP *bmp, const RGB *pal) {
-#ifdef SCUMM_LITTLE_ENDIAN
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#else
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#endif
+ const Graphics::PixelFormat requiredFormat_3byte = Graphics::PixelFormat::createFormatBGR24();
Graphics::ManagedSurface surface(bmp->w, bmp->h, requiredFormat_3byte);
Graphics::ManagedSurface &src = bmp->getSurface();
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 60b37910c6c..3041e94a7d9 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -46,7 +46,6 @@ Renderer::Renderer(int screenW, int screenH, Common::RenderMode renderMode, bool
_screenW = screenW;
_screenH = screenH;
_currentPixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
- _palettePixelFormat = Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
_keyColor = -1;
_inkColor = -1;
_paperColor = -1;
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index e3e632e7580..57eb93d17b8 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -63,7 +63,6 @@ public:
virtual ~Renderer();
Graphics::PixelFormat _currentPixelFormat;
- Graphics::PixelFormat _palettePixelFormat;
Graphics::PixelFormat _texturePixelFormat;
bool _isAccelerated;
bool _authenticGraphics;
diff --git a/engines/grim/material.cpp b/engines/grim/material.cpp
index 005b697355d..eb29c541f0d 100644
--- a/engines/grim/material.cpp
+++ b/engines/grim/material.cpp
@@ -50,11 +50,10 @@ MaterialData::MaterialData(const Common::String &filename, Common::SeekableReadS
}
static void loadImage(Image::ImageDecoder *decoder, Texture *t) {
+ const Graphics::PixelFormat format_3bpp = Graphics::PixelFormat::createFormatRGB24();
#ifdef SCUMM_BIG_ENDIAN
- const Graphics::PixelFormat format_3bpp(3, 8, 8, 8, 0, 16, 8, 0, 0);
const Graphics::PixelFormat format_4bpp(4, 8, 8, 8, 8, 24, 16, 8, 0);
#else
- const Graphics::PixelFormat format_3bpp(3, 8, 8, 8, 0, 0, 8, 16, 0);
const Graphics::PixelFormat format_4bpp(4, 8, 8, 8, 8, 0, 8, 16, 24);
#endif
diff --git a/engines/playground3d/playground3d.cpp b/engines/playground3d/playground3d.cpp
index cc020350e70..a3e4d2ebdea 100644
--- a/engines/playground3d/playground3d.cpp
+++ b/engines/playground3d/playground3d.cpp
@@ -58,11 +58,10 @@ bool Playground3dEngine::hasFeature(EngineFeature f) const {
void Playground3dEngine::genTextures() {
#if defined(SCUMM_LITTLE_ENDIAN)
Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 0, 8, 16, 24);
- Graphics::PixelFormat pixelFormatRGB(3, 8, 8, 8, 0, 0, 8, 16, 0);
#else
Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 24, 16, 8, 0);
- Graphics::PixelFormat pixelFormatRGB(3, 8, 8, 8, 0, 16, 8, 0, 0);
#endif
+ Graphics::PixelFormat pixelFormatRGB = Graphics::PixelFormat::createFormatRGB24();
Graphics::PixelFormat pixelFormatRGB565(2, 5, 6, 5, 0, 11, 5, 0, 0);
Graphics::PixelFormat pixelFormatRGB5551(2, 5, 5, 5, 1, 11, 6, 1, 0);
Graphics::PixelFormat pixelFormatRGB4444(2, 4, 4, 4, 4, 12, 8, 4, 0);
diff --git a/engines/stark/formats/dds.cpp b/engines/stark/formats/dds.cpp
index f9e0ff68102..107a74e350d 100644
--- a/engines/stark/formats/dds.cpp
+++ b/engines/stark/formats/dds.cpp
@@ -179,11 +179,7 @@ bool DDS::detectFormat(const DDSPixelFormat &format) {
(format.bitCount == 24) &&
(format.rBitMask == 0x00FF0000) && (format.gBitMask == 0x0000FF00) &&
(format.bBitMask == 0x000000FF)) {
-#ifdef SCUMM_BIG_ENDIAN
- _format = Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#else
- _format = Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#endif
+ _format = Graphics::PixelFormat::createFormatBGR24();
return true;
} else {
warning("Unsupported pixel format (%X, %X, %d, %X, %X, %X, %X) for %s",
diff --git a/engines/ultima/ultima4/gfx/imageloader.cpp b/engines/ultima/ultima4/gfx/imageloader.cpp
index 2f1c909ac86..c7ce8be790a 100644
--- a/engines/ultima/ultima4/gfx/imageloader.cpp
+++ b/engines/ultima/ultima4/gfx/imageloader.cpp
@@ -94,14 +94,12 @@ Graphics::PixelFormat U4ImageDecoder::getPixelFormatForBpp() const {
case 4:
case 8:
return Graphics::PixelFormat::createFormatCLUT8();
-#ifdef SCUMM_LITTLE_ENDIAN
case 24:
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
+ return Graphics::PixelFormat::createFormatRGB24();
+#ifdef SCUMM_LITTLE_ENDIAN
case 32:
return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
#else
- case 24:
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
case 32:
return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
#endif
diff --git a/graphics/opengl/texture.h b/graphics/opengl/texture.h
index 866b3b00909..03f60a54f86 100644
--- a/graphics/opengl/texture.h
+++ b/graphics/opengl/texture.h
@@ -163,11 +163,7 @@ public:
GLuint getGLTexture() const { return _glTexture; }
static inline const Graphics::PixelFormat getRGBPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#else
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#endif
+ return Graphics::PixelFormat::createFormatRGB24();
}
static inline const Graphics::PixelFormat getRGBAPixelFormat() {
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index 4ba16d8d915..6c77097b7f7 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -185,6 +185,24 @@ struct PixelFormat {
return PixelFormat(1, 0, 0, 0, 0, 0, 0, 0, 0);
}
+ /** Define an endian-aware RGB24 pixel format. */
+ static inline PixelFormat createFormatRGB24() {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
+#else
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
+#endif
+ }
+
+ /** Define an endian-aware BGR24 pixel format. */
+ static inline PixelFormat createFormatBGR24() {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
+#else
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
+#endif
+ }
+
/** Check if two pixel formats are the same */
inline bool operator==(const PixelFormat &fmt) const {
return bytesPerPixel == fmt.bytesPerPixel &&
diff --git a/graphics/tinygl/init.cpp b/graphics/tinygl/init.cpp
index 247ae7f2842..5990dfc5bb3 100644
--- a/graphics/tinygl/init.cpp
+++ b/graphics/tinygl/init.cpp
@@ -239,11 +239,10 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
#if defined(SCUMM_LITTLE_ENDIAN)
colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE});
- colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), TGL_RGB, TGL_UNSIGNED_BYTE});
#else
colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), TGL_RGBA, TGL_UNSIGNED_BYTE});
- colorAssociationList.push_back({Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0), TGL_RGB, TGL_UNSIGNED_BYTE});
#endif
+ colorAssociationList.push_back({Graphics::PixelFormat::createFormatRGB24(), TGL_RGB, TGL_UNSIGNED_BYTE});
colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), TGL_RGB, TGL_UNSIGNED_SHORT_5_6_5});
colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_5_5_5_1});
colorAssociationList.push_back({Graphics::PixelFormat(2, 4, 4, 4, 4, 12, 8, 4, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_4_4_4_4});
diff --git a/image/bmp.cpp b/image/bmp.cpp
index 0f841e4ef0b..ffc68406c1f 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -148,11 +148,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
}
bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette) {
-#ifdef SCUMM_LITTLE_ENDIAN
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#else
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#endif
+ const Graphics::PixelFormat requiredFormat_3byte = Graphics::PixelFormat::createFormatBGR24();
Graphics::Surface *tmp = NULL;
const Graphics::Surface *surface;
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index 9f4cdeb7195..fc64e06f368 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -129,14 +129,12 @@ Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
return Graphics::PixelFormat::createFormatCLUT8();
case 16:
return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
-#ifdef SCUMM_LITTLE_ENDIAN
case 24:
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
+ return Graphics::PixelFormat::createFormatBGR24();
+#ifdef SCUMM_LITTLE_ENDIAN
case 32:
return Graphics::PixelFormat(4, 8, 8, 8, _ignoreAlpha ? 0 : 8, 16, 8, 0, 24);
#else
- case 24:
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
case 32:
return Graphics::PixelFormat(4, 8, 8, 8, _ignoreAlpha ? 0 : 8, 8, 16, 24, 0);
#endif
diff --git a/image/jpeg.cpp b/image/jpeg.cpp
index be9c688bf23..4122dc03ec4 100644
--- a/image/jpeg.cpp
+++ b/image/jpeg.cpp
@@ -57,11 +57,7 @@ JPEGDecoder::~JPEGDecoder() {
}
Graphics::PixelFormat JPEGDecoder::getByteOrderRgbPixelFormat() const {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#else
- return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#endif
+ return Graphics::PixelFormat::createFormatRGB24();
}
const Graphics::Surface *JPEGDecoder::getSurface() const {
diff --git a/image/png.cpp b/image/png.cpp
index 95fc896480b..40aa0a96f04 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -299,11 +299,10 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette) {
#ifdef USE_PNG
+ const Graphics::PixelFormat requiredFormat_3byte = Graphics::PixelFormat::createFormatRGB24();
#ifdef SCUMM_LITTLE_ENDIAN
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 0, 8, 16, 24);
#else
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 16, 8, 0, 0);
const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 24, 16, 8, 0);
#endif
diff --git a/test/image/blending.h b/test/image/blending.h
index a80ec44bdc8..dc6a4770c5f 100644
--- a/test/image/blending.h
+++ b/test/image/blending.h
@@ -749,11 +749,7 @@ OldTransparentSurface *OldTransparentSurface::scale(int16 newWidth, int16 newHei
static int save_bitmap(const char *path, const Graphics::ManagedSurface *surf) {
Common::FSNode fileNode(path);
Common::SeekableWriteStream *out = fileNode.createWriteStream();
-#ifdef SCUMM_LITTLE_ENDIAN
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 16, 8, 0, 0);
-#else
- const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
-#endif
+ const Graphics::PixelFormat requiredFormat_3byte = Graphics::PixelFormat::createFormatBGR24();
Graphics::ManagedSurface surface(surf->w, surf->h, requiredFormat_3byte);
// Copy from the source surface without alpha transparency
Commit: 62851abfa11d82ef33cef0286c9b7eae8f0aa438
https://github.com/scummvm/scummvm/commit/62851abfa11d82ef33cef0286c9b7eae8f0aa438
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-06-19T14:17:51+03:00
Commit Message:
GRAPHICS: Add helper functions for creating RGBA32 and BGRA32 formats
Changed paths:
backends/graphics/opengl/opengl-graphics.cpp
backends/graphics/opengl/texture.cpp
engines/freescape/gfx.cpp
engines/gnap/gnap.cpp
engines/grim/bitmap.cpp
engines/grim/emi/lua_v2.cpp
engines/grim/gfx_opengl.cpp
engines/grim/gfx_opengl_shaders.cpp
engines/grim/material.cpp
engines/hpl1/engine/graphics/bitmap2D.cpp
engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
engines/hpl1/opengl.cpp
engines/myst3/gfx.cpp
engines/myst3/myst3.cpp
engines/myst3/state.cpp
engines/playground3d/playground3d.cpp
engines/stark/formats/dds.cpp
engines/stark/gfx/driver.cpp
engines/ultima/ultima4/gfx/imageloader.cpp
engines/wintermute/base/gfx/base_renderer3d.cpp
engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
graphics/opengl/texture.h
graphics/pixelformat.h
graphics/svg.cpp
graphics/tinygl/init.cpp
image/codecs/bmp_raw.cpp
image/png.cpp
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index bbc2259c027..1319f4a4519 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1702,11 +1702,7 @@ Surface *OpenGLGraphicsManager::createSurface(const Graphics::PixelFormat &forma
// hope for this to change anytime soon) we use pixel format
// conversion to a supported texture format.
return new TextureSurfaceRGB555();
-#ifdef SCUMM_LITTLE_ENDIAN
- } else if (format == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) { // RGBA8888
-#else
- } else if (format == Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) { // ABGR8888
-#endif
+ } else if (format == Graphics::PixelFormat::createFormatABGR32()) {
return new TextureSurfaceRGBA8888Swap();
} else {
return new FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), format);
diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index 36705fd01fe..f1d4feeea54 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -368,11 +368,7 @@ void TextureSurfaceRGB555::updateGLTexture() {
}
TextureSurfaceRGBA8888Swap::TextureSurfaceRGBA8888Swap()
-#ifdef SCUMM_LITTLE_ENDIAN
- : FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) // RGBA8888 -> ABGR8888
-#else
- : FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) // ABGR8888 -> RGBA8888
-#endif
+ : FakeTextureSurface(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, OpenGL::Texture::getRGBAPixelFormat(), Graphics::PixelFormat::createFormatABGR32())
{
}
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 3041e94a7d9..3aff643aa8f 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -35,11 +35,7 @@
namespace Freescape {
const Graphics::PixelFormat getRGBAPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
Renderer::Renderer(int screenW, int screenH, Common::RenderMode renderMode, bool authenticGraphics) {
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp
index 659f8763af4..8a6ed175d86 100644
--- a/engines/gnap/gnap.cpp
+++ b/engines/gnap/gnap.cpp
@@ -194,12 +194,8 @@ GnapEngine::~GnapEngine() {
}
Common::Error GnapEngine::run() {
- // Initialize the graphics mode to RGBA8888
-#if defined(SCUMM_BIG_ENDIAN)
- Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#else
- Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#endif
+ // Initialize the graphics mode to ABGR32
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatABGR32();
initGraphics(800, 600, &format);
// We do not support color conversion yet
diff --git a/engines/grim/bitmap.cpp b/engines/grim/bitmap.cpp
index 35cbd6cbf11..6b19e69a90e 100644
--- a/engines/grim/bitmap.cpp
+++ b/engines/grim/bitmap.cpp
@@ -309,11 +309,7 @@ bool BitmapData::loadTile(Common::SeekableReadStream *o) {
_data = new Graphics::Surface[_numImages];
Graphics::PixelFormat format_16bpp = Graphics::PixelFormat(2, 5, 5, 5, 1, 0, 5, 10, 15);
-#ifdef SCUMM_BIG_ENDIAN
- Graphics::PixelFormat format_32bpp = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- Graphics::PixelFormat format_32bpp = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ Graphics::PixelFormat format_32bpp = Graphics::PixelFormat::createFormatRGBA32();
int width = 256;
int height = 256;
diff --git a/engines/grim/emi/lua_v2.cpp b/engines/grim/emi/lua_v2.cpp
index 302566f6ef6..7cb952407a2 100644
--- a/engines/grim/emi/lua_v2.cpp
+++ b/engines/grim/emi/lua_v2.cpp
@@ -503,11 +503,7 @@ void Lua_V2::ThumbnailFromFile() {
return;
}
-#ifdef SCUMM_BIG_ENDIAN
- screenshot->_data->convertToColorFormat(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
-#else
- screenshot->_data->convertToColorFormat(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-#endif
+ screenshot->_data->convertToColorFormat(Graphics::PixelFormat::createFormatRGBA32());
g_driver->createSpecialtyTexture(index, (const uint8 *)screenshot->getData(0).getPixels(), width, height);
delete screenshot;
delete[] data;
diff --git a/engines/grim/gfx_opengl.cpp b/engines/grim/gfx_opengl.cpp
index ed7feacd423..45a93d505cf 100644
--- a/engines/grim/gfx_opengl.cpp
+++ b/engines/grim/gfx_opengl.cpp
@@ -1088,11 +1088,7 @@ void GfxOpenGL::createBitmap(BitmapData *bitmap) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap->_width);
const Graphics::PixelFormat format_16bpp(2, 5, 6, 5, 0, 11, 5, 0, 0);
-#ifdef SCUMM_BIG_ENDIAN
- const Graphics::PixelFormat format_32bpp(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- const Graphics::PixelFormat format_32bpp(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ const Graphics::PixelFormat format_32bpp = Graphics::PixelFormat::createFormatRGBA32();
for (int pic = 0; pic < bitmap->_numImages; pic++) {
const Graphics::Surface &imageData = bitmap->getImageData(pic);
@@ -1679,11 +1675,7 @@ void GfxOpenGL::drawDepthBitmap(int x, int y, int w, int h, const char *data) {
}
const Graphics::PixelFormat GfxOpenGL::getMovieFormat() const {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
void GfxOpenGL::prepareMovieFrame(Graphics::Surface *frame) {
@@ -1871,11 +1863,7 @@ void GfxOpenGL::drawEmergString(int x, int y, const char *text, const Color &fgC
Bitmap *GfxOpenGL::getScreenshot(int w, int h, bool useStored) {
Graphics::Surface src;
-#ifdef SCUMM_BIG_ENDIAN
- src.create(_screenWidth, _screenHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
-#else
- src.create(_screenWidth, _screenHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-#endif
+ src.create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatRGBA32());
if (useStored) {
memcpy(src.getPixels(), _storedDisplay, _screenWidth * _screenHeight * 4);
} else {
diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp
index ba6446d229b..16f8c8ad150 100644
--- a/engines/grim/gfx_opengl_shaders.cpp
+++ b/engines/grim/gfx_opengl_shaders.cpp
@@ -1360,11 +1360,7 @@ void GfxOpenGLS::createBitmap(BitmapData *bitmap) {
glPixelStorei(GL_UNPACK_ALIGNMENT, bytes);
const Graphics::PixelFormat format_16bpp(2, 5, 6, 5, 0, 11, 5, 0, 0);
-#ifdef SCUMM_BIG_ENDIAN
- const Graphics::PixelFormat format_32bpp(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- const Graphics::PixelFormat format_32bpp(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ const Graphics::PixelFormat format_32bpp = Graphics::PixelFormat::createFormatRGBA32();
for (int pic = 0; pic < bitmap->_numImages; pic++) {
const Graphics::Surface &imageData = bitmap->getImageData(pic);
@@ -2001,11 +1997,7 @@ void GfxOpenGLS::drawPolygon(const PrimitiveObject *primitive) {
}
const Graphics::PixelFormat GfxOpenGLS::getMovieFormat() const {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
void GfxOpenGLS::prepareMovieFrame(Graphics::Surface* frame) {
@@ -2224,11 +2216,7 @@ static void readPixels(int x, int y, int width, int height, byte *buffer) {
Bitmap *GfxOpenGLS::getScreenshot(int w, int h, bool useStored) {
Graphics::Surface src;
-#ifdef SCUMM_BIG_ENDIAN
- src.create(_screenWidth, _screenHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
-#else
- src.create(_screenWidth, _screenHeight, Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-#endif
+ src.create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatRGBA32());
Bitmap *bmp;
if (useStored) {
diff --git a/engines/grim/material.cpp b/engines/grim/material.cpp
index eb29c541f0d..c41e665fe9e 100644
--- a/engines/grim/material.cpp
+++ b/engines/grim/material.cpp
@@ -51,11 +51,7 @@ MaterialData::MaterialData(const Common::String &filename, Common::SeekableReadS
static void loadImage(Image::ImageDecoder *decoder, Texture *t) {
const Graphics::PixelFormat format_3bpp = Graphics::PixelFormat::createFormatRGB24();
-#ifdef SCUMM_BIG_ENDIAN
- const Graphics::PixelFormat format_4bpp(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- const Graphics::PixelFormat format_4bpp(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ const Graphics::PixelFormat format_4bpp = Graphics::PixelFormat::createFormatRGBA32();
const Graphics::Surface *surface = decoder->getSurface();
diff --git a/engines/hpl1/engine/graphics/bitmap2D.cpp b/engines/hpl1/engine/graphics/bitmap2D.cpp
index e22d21e587f..494162d778a 100644
--- a/engines/hpl1/engine/graphics/bitmap2D.cpp
+++ b/engines/hpl1/engine/graphics/bitmap2D.cpp
@@ -41,11 +41,7 @@ static Image::ImageDecoder *loadImage(const tString &filepath, Image::ImageDecod
}
Image::JPEGDecoder *setupJPEGDecoder(Image::JPEGDecoder *jpeg) {
-#ifdef SCUMM_BIG_ENDIAN
- jpeg->setOutputPixelFormat(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
-#else
- jpeg->setOutputPixelFormat(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-#endif
+ jpeg->setOutputPixelFormat(Graphics::PixelFormat::createFormatRGBA32());
return jpeg;
}
diff --git a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
index 8c24845767a..02097f84ac5 100644
--- a/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
+++ b/engines/hpl1/engine/impl/LowLevelGraphicsSDL.cpp
@@ -96,11 +96,7 @@ cLowLevelGraphicsSDL::cLowLevelGraphicsSDL() {
mvVirtualSize.y = 600;
mfGammaCorrection = 1.0;
mpRenderTarget = nullptr;
-#ifdef SCUMM_BIG_ENDIAN
- mpPixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- mpPixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ mpPixelFormat = Graphics::PixelFormat::createFormatRGBA32();
Common::fill(mpCurrentTexture, mpCurrentTexture + MAX_TEXTUREUNITS, nullptr);
diff --git a/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp b/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
index e79d14a6faa..163ca83edd7 100644
--- a/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
+++ b/engines/hpl1/engine/impl/low_level_graphics_tgl.cpp
@@ -312,11 +312,7 @@ LowLevelGraphicsTGL::LowLevelGraphicsTGL() {
mvVirtualSize.y = 600;
mfGammaCorrection = 1.0;
mpRenderTarget = nullptr;
-#ifdef SCUMM_BIG_ENDIAN
- mpPixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- mpPixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ mpPixelFormat = Graphics::PixelFormat::createFormatRGBA32();
Common::fill(mpCurrentTexture, mpCurrentTexture + MAX_TEXTUREUNITS, nullptr);
diff --git a/engines/hpl1/opengl.cpp b/engines/hpl1/opengl.cpp
index be9b7bb0092..6312f229de9 100644
--- a/engines/hpl1/opengl.cpp
+++ b/engines/hpl1/opengl.cpp
@@ -54,11 +54,7 @@ static Common::Rect getGLViewport() {
}
static Graphics::PixelFormat getRGBAPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
Common::ScopedPtr<Graphics::Surface> createGLViewportScreenshot() {
diff --git a/engines/myst3/gfx.cpp b/engines/myst3/gfx.cpp
index 0d330f291a6..467b3250edd 100644
--- a/engines/myst3/gfx.cpp
+++ b/engines/myst3/gfx.cpp
@@ -300,11 +300,7 @@ Common::Point Window::scalePoint(const Common::Point &screen) const {
}
const Graphics::PixelFormat Texture::getRGBAPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
} // End of namespace Myst3
diff --git a/engines/myst3/myst3.cpp b/engines/myst3/myst3.cpp
index a9665548935..bccbf9db312 100644
--- a/engines/myst3/myst3.cpp
+++ b/engines/myst3/myst3.cpp
@@ -1423,11 +1423,7 @@ Graphics::Surface *Myst3Engine::loadTexture(uint16 id) {
data->readUint32LE(); // unk 2
data->readUint32LE(); // unk 3
-#ifdef SCUMM_BIG_ENDIAN
- Graphics::PixelFormat onDiskFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
-#else
- Graphics::PixelFormat onDiskFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
-#endif
+ Graphics::PixelFormat onDiskFormat = Graphics::PixelFormat::createFormatARGB32();
Graphics::Surface *s = new Graphics::Surface();
s->create(width, height, onDiskFormat);
diff --git a/engines/myst3/state.cpp b/engines/myst3/state.cpp
index 281605fe302..4655def13ee 100644
--- a/engines/myst3/state.cpp
+++ b/engines/myst3/state.cpp
@@ -479,11 +479,7 @@ Common::Error GameState::StateData::syncWithSaveGame(Common::Serializer &s) {
}
const Graphics::PixelFormat GameState::getThumbnailSavePixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 0, 8, 16, 24, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 0, 16, 8, 0, 24);
-#endif
+ return Graphics::PixelFormat::createFormatBGRA32(false);
}
Graphics::Surface *GameState::readThumbnail(Common::ReadStream *inStream) {
diff --git a/engines/playground3d/playground3d.cpp b/engines/playground3d/playground3d.cpp
index a3e4d2ebdea..e18a30a611e 100644
--- a/engines/playground3d/playground3d.cpp
+++ b/engines/playground3d/playground3d.cpp
@@ -56,11 +56,7 @@ bool Playground3dEngine::hasFeature(EngineFeature f) const {
}
void Playground3dEngine::genTextures() {
-#if defined(SCUMM_LITTLE_ENDIAN)
- Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#else
- Graphics::PixelFormat pixelFormatRGBA(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#endif
+ Graphics::PixelFormat pixelFormatRGBA = Graphics::PixelFormat::createFormatRGBA32();
Graphics::PixelFormat pixelFormatRGB = Graphics::PixelFormat::createFormatRGB24();
Graphics::PixelFormat pixelFormatRGB565(2, 5, 6, 5, 0, 11, 5, 0, 0);
Graphics::PixelFormat pixelFormatRGB5551(2, 5, 5, 5, 1, 11, 6, 1, 0);
diff --git a/engines/stark/formats/dds.cpp b/engines/stark/formats/dds.cpp
index 107a74e350d..f7460255c9c 100644
--- a/engines/stark/formats/dds.cpp
+++ b/engines/stark/formats/dds.cpp
@@ -169,11 +169,7 @@ bool DDS::detectFormat(const DDSPixelFormat &format) {
(format.bitCount == 32) &&
(format.rBitMask == 0x00FF0000) && (format.gBitMask == 0x0000FF00) &&
(format.bBitMask == 0x000000FF) && (format.aBitMask == 0xFF000000)) {
-#ifdef SCUMM_BIG_ENDIAN
- _format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 0, 8, 16);
-#else
- _format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
-#endif
+ _format = Graphics::PixelFormat::createFormatBGRA32();
return true;
} else if (!(format.flags & kPixelFlagsHasAlpha) &&
(format.bitCount == 24) &&
diff --git a/engines/stark/gfx/driver.cpp b/engines/stark/gfx/driver.cpp
index cafee765d5f..58de9a97f13 100644
--- a/engines/stark/gfx/driver.cpp
+++ b/engines/stark/gfx/driver.cpp
@@ -83,11 +83,7 @@ Driver *Driver::create() {
}
const Graphics::PixelFormat Driver::getRGBAPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
bool Driver::computeScreenViewport() {
diff --git a/engines/ultima/ultima4/gfx/imageloader.cpp b/engines/ultima/ultima4/gfx/imageloader.cpp
index c7ce8be790a..86de036f8b3 100644
--- a/engines/ultima/ultima4/gfx/imageloader.cpp
+++ b/engines/ultima/ultima4/gfx/imageloader.cpp
@@ -96,13 +96,8 @@ Graphics::PixelFormat U4ImageDecoder::getPixelFormatForBpp() const {
return Graphics::PixelFormat::createFormatCLUT8();
case 24:
return Graphics::PixelFormat::createFormatRGB24();
-#ifdef SCUMM_LITTLE_ENDIAN
case 32:
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#else
- case 32:
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
default:
error("invalid bits-per-pixel (bpp): %d", _bpp);
}
diff --git a/engines/wintermute/base/gfx/base_renderer3d.cpp b/engines/wintermute/base/gfx/base_renderer3d.cpp
index 315bfb69b66..813f7a09394 100644
--- a/engines/wintermute/base/gfx/base_renderer3d.cpp
+++ b/engines/wintermute/base/gfx/base_renderer3d.cpp
@@ -132,11 +132,7 @@ DXViewport BaseRenderer3D::getViewPort() {
}
Graphics::PixelFormat BaseRenderer3D::getPixelFormat() const {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
bool BaseRenderer3D::flip() {
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
index 8b40a033b90..b5c3346fd32 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d.cpp
@@ -636,11 +636,7 @@ void BaseRenderOpenGL3D::fadeToColor(byte r, byte g, byte b, byte a) {
BaseImage *BaseRenderOpenGL3D::takeScreenshot(int newWidth, int newHeight) {
BaseImage *screenshot = new BaseImage();
Graphics::Surface *surface = new Graphics::Surface();
-#ifdef SCUMM_BIG_ENDIAN
- Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- Graphics::PixelFormat format(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGBA32();
surface->create(_viewportRect.width(), _viewportRect.height(), format);
glReadPixels(_viewportRect.left, _viewportRect.height() - _viewportRect.bottom,
diff --git a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
index b8dfd146fd6..afd9c746882 100644
--- a/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_render_opengl3d_shader.cpp
@@ -734,11 +734,7 @@ void BaseRenderOpenGL3DShader::fadeToColor(byte r, byte g, byte b, byte a) {
BaseImage *BaseRenderOpenGL3DShader::takeScreenshot(int newWidth, int newHeight) {
BaseImage *screenshot = new BaseImage();
Graphics::Surface *surface = new Graphics::Surface();
-#ifdef SCUMM_BIG_ENDIAN
- Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- Graphics::PixelFormat format(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGBA32();
surface->create(_viewportRect.width(), _viewportRect.height(), format);
glReadPixels(_viewportRect.left, _viewportRect.height() - _viewportRect.bottom,
diff --git a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
index 9f04972394e..eb62444f802 100644
--- a/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
+++ b/engines/wintermute/base/gfx/opengl/base_surface_opengl3d.cpp
@@ -149,11 +149,7 @@ bool BaseSurfaceOpenGL3D::create(const Common::String &filename, bool defaultCK,
_imageData = nullptr;
}
-#ifdef SCUMM_BIG_ENDIAN
- _imageData = img.getSurface()->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), img.getPalette(), img.getPaletteCount());
-#else
- _imageData = img.getSurface()->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), img.getPalette(), img.getPaletteCount());
-#endif
+ _imageData = img.getSurface()->convertTo(Graphics::PixelFormat::createFormatRGBA32(), img.getPalette(), img.getPaletteCount());
if (_filename.matchString("savegame:*g", true)) {
uint8 r, g, b, a;
@@ -343,11 +339,7 @@ bool BaseSurfaceOpenGL3D::setAlphaImage(const Common::String &filename) {
Graphics::AlphaType type = alphaImage->getSurface()->detectAlpha();
if (type != Graphics::ALPHA_OPAQUE) {
-#ifdef SCUMM_BIG_ENDIAN
- _maskData = alphaImage->getSurface()->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
-#else
- _maskData = alphaImage->getSurface()->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
-#endif
+ _maskData = alphaImage->getSurface()->convertTo(Graphics::PixelFormat::createFormatRGBA32());
}
delete alphaImage;
diff --git a/graphics/opengl/texture.h b/graphics/opengl/texture.h
index 03f60a54f86..2cfef161cda 100644
--- a/graphics/opengl/texture.h
+++ b/graphics/opengl/texture.h
@@ -167,19 +167,11 @@ public:
}
static inline const Graphics::PixelFormat getRGBAPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32();
}
static inline const Graphics::PixelFormat getBGRAPixelFormat() {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
-#endif
+ return Graphics::PixelFormat::createFormatBGRA32();
}
protected:
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index 6c77097b7f7..e2609e84b9f 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -203,6 +203,42 @@ struct PixelFormat {
#endif
}
+ /** Define an endian-aware RGBA32 pixel format. */
+ static inline PixelFormat createFormatRGBA32(bool alpha = true) {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 24, 16, 8, 0);
+#else
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 0, 8, 16, 24);
+#endif
+ }
+
+ /** Define an endian-aware BGRA32 pixel format. */
+ static inline PixelFormat createFormatBGRA32(bool alpha = true) {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 8, 16, 24, 0);
+#else
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 16, 8, 0, 24);
+#endif
+ }
+
+ /** Define an endian-aware ABGR32 pixel format. */
+ static inline PixelFormat createFormatABGR32(bool alpha = true) {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 0, 8, 16, 24);
+#else
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 24, 16, 8, 0);
+#endif
+ }
+
+ /** Define an endian-aware ARGB32 pixel format. */
+ static inline PixelFormat createFormatARGB32(bool alpha = true) {
+#ifdef SCUMM_BIG_ENDIAN
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 16, 8, 0, 24);
+#else
+ return Graphics::PixelFormat(4, 8, 8, 8, alpha ? 8 : 0, 8, 16, 24, 0);
+#endif
+ }
+
/** Check if two pixel formats are the same */
inline bool operator==(const PixelFormat &fmt) const {
return bytesPerPixel == fmt.bytesPerPixel &&
diff --git a/graphics/svg.cpp b/graphics/svg.cpp
index 010d3bab5f1..6a8bf16affe 100644
--- a/graphics/svg.cpp
+++ b/graphics/svg.cpp
@@ -29,11 +29,7 @@
#define NANOSVGRAST_IMPLEMENTATION
#include "graphics/nanosvg/nanosvgrast.h"
-#ifdef SCUMM_BIG_ENDIAN
-#define PIXELFORMAT Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)
-#else
-#define PIXELFORMAT Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)
-#endif
+#define PIXELFORMAT Graphics::PixelFormat::createFormatRGBA32()
namespace Graphics {
diff --git a/graphics/tinygl/init.cpp b/graphics/tinygl/init.cpp
index 5990dfc5bb3..811b4b380d8 100644
--- a/graphics/tinygl/init.cpp
+++ b/graphics/tinygl/init.cpp
@@ -237,11 +237,7 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
maxTextureName = 0;
texture_mag_filter = TGL_LINEAR;
texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
-#if defined(SCUMM_LITTLE_ENDIAN)
- colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24), TGL_RGBA, TGL_UNSIGNED_BYTE});
-#else
- colorAssociationList.push_back({Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), TGL_RGBA, TGL_UNSIGNED_BYTE});
-#endif
+ colorAssociationList.push_back({Graphics::PixelFormat::createFormatRGBA32(), TGL_RGBA, TGL_UNSIGNED_BYTE});
colorAssociationList.push_back({Graphics::PixelFormat::createFormatRGB24(), TGL_RGB, TGL_UNSIGNED_BYTE});
colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), TGL_RGB, TGL_UNSIGNED_SHORT_5_6_5});
colorAssociationList.push_back({Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0), TGL_RGBA, TGL_UNSIGNED_SHORT_5_5_5_1});
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index fc64e06f368..e409dcc78a8 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -131,13 +131,8 @@ Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
case 24:
return Graphics::PixelFormat::createFormatBGR24();
-#ifdef SCUMM_LITTLE_ENDIAN
case 32:
- return Graphics::PixelFormat(4, 8, 8, 8, _ignoreAlpha ? 0 : 8, 16, 8, 0, 24);
-#else
- case 32:
- return Graphics::PixelFormat(4, 8, 8, 8, _ignoreAlpha ? 0 : 8, 8, 16, 24, 0);
-#endif
+ return Graphics::PixelFormat::createFormatBGRA32(!_ignoreAlpha);
default:
break;
}
diff --git a/image/png.cpp b/image/png.cpp
index 40aa0a96f04..a48afbf763b 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -63,11 +63,7 @@ void PNGDecoder::destroy() {
}
Graphics::PixelFormat PNGDecoder::getByteOrderRgbaPixelFormat(bool isAlpha) const {
-#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, isAlpha ? 8 : 0, 24, 16, 8, 0);
-#else
- return Graphics::PixelFormat(4, 8, 8, 8, isAlpha ? 8 : 0, 0, 8, 16, 24);
-#endif
+ return Graphics::PixelFormat::createFormatRGBA32(isAlpha);
}
#ifdef USE_PNG
@@ -300,11 +296,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette) {
#ifdef USE_PNG
const Graphics::PixelFormat requiredFormat_3byte = Graphics::PixelFormat::createFormatRGB24();
-#ifdef SCUMM_LITTLE_ENDIAN
- const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 0, 8, 16, 24);
-#else
- const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 24, 16, 8, 0);
-#endif
+ const Graphics::PixelFormat requiredFormat_4byte = Graphics::PixelFormat::createFormatRGBA32();
int colorType;
Graphics::Surface *tmp = NULL;
More information about the Scummvm-git-logs
mailing list