https://github.com/libsdl-org/Maelstrom/commit/baa269a602de17320dbf30dbe89391881aad1893
From baa269a602de17320dbf30dbe89391881aad1893 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 24 Nov 2011 10:03:53 -0500
Subject: [PATCH] Temporary code to dump all the images as BMP files
---
game/MaelstromUI.cpp | 4 +++-
game/init.cpp | 12 ++++++++----
game/load.cpp | 5 +++--
screenlib/SDL_FrameBuf.cpp | 5 ++++-
screenlib/SDL_FrameBuf.h | 2 +-
5 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/game/MaelstromUI.cpp b/game/MaelstromUI.cpp
index 2a32fa2f..cb3f0dfc 100644
--- a/game/MaelstromUI.cpp
+++ b/game/MaelstromUI.cpp
@@ -374,7 +374,7 @@ UIDrawEngineSprite::Load(rapidxml::xml_node<> *node, const UITemplates *template
{
rapidxml::xml_attribute<> *attr;
int baseID;
- Mac_ResData *S, *M;
+ //Mac_ResData *S, *M;
if (!UIDrawEngine::Load(node, templates)) {
return false;
@@ -388,6 +388,7 @@ UIDrawEngineSprite::Load(rapidxml::xml_node<> *node, const UITemplates *template
baseID = SDL_atoi(attr->value());
/* Load the image */
+/*
SDL_Texture *image = NULL;
if ((S = spriteres->Resource("icl8", baseID)) != NULL &&
(M = spriteres->Resource("ICN#", baseID)) != NULL) {
@@ -398,6 +399,7 @@ UIDrawEngineSprite::Load(rapidxml::xml_node<> *node, const UITemplates *template
return false;
}
m_element->SetImage(image);
+*/
return true;
}
diff --git a/game/init.cpp b/game/init.cpp
index bab1057b..3688b42b 100644
--- a/game/init.cpp
+++ b/game/init.cpp
@@ -206,8 +206,8 @@ static void InitShots(void)
int xx = 30;
/* Load the shot images */
- gPlayerShot = screen->LoadImage(SHOT_SIZE,SHOT_SIZE,gPlayerShotColors);
- gEnemyShot = screen->LoadImage(SHOT_SIZE, SHOT_SIZE, gEnemyShotColors);
+ gPlayerShot = screen->LoadImage(SHOT_SIZE, SHOT_SIZE, gPlayerShotColors, NULL, "PlayerShot.bmp");
+ gEnemyShot = screen->LoadImage(SHOT_SIZE, SHOT_SIZE, gEnemyShotColors, NULL, "EnemyShot.bmp");
/* Now setup the shot origin table */
@@ -1087,7 +1087,9 @@ static int LoadSprite(Mac_Resource *spriteres,
SetRect(&aBlit->hitRect, left, top, right, bottom);
/* Load the image */
- aBlit->sprite[index] = screen->LoadImage(32, 32, S->data, mask);
+char file[32];
+sprintf(file, "ICN#%d.bmp", baseID+index);
+ aBlit->sprite[index] = screen->LoadImage(32, 32, S->data, mask, file);
if ( aBlit->sprite[index] == NULL ) {
error(
"LoadSprite(%d+%d): Couldn't convert sprite image!\n", baseID, index);
@@ -1208,7 +1210,9 @@ static int LoadSmallSprite(Mac_Resource *spriteres,
SetRect(&aBlit->hitRect, left, top, right, bottom);
/* Load the image */
- aBlit->sprite[index] = screen->LoadImage(16, 16, S->data, mask);
+char file[32];
+sprintf(file, "ics#%d.bmp", baseID+index);
+ aBlit->sprite[index] = screen->LoadImage(16, 16, S->data, mask, file);
if ( aBlit->sprite[index] == NULL ) {
error(
"LoadSprite(%d+%d): Couldn't convert sprite image!\n", baseID, index);
diff --git a/game/load.cpp b/game/load.cpp
index c70161c8..03f25705 100644
--- a/game/load.cpp
+++ b/game/load.cpp
@@ -43,7 +43,7 @@ SDL_Texture *Load_Title(FrameBuf *screen, int title_id)
}
/* Create an image from the BMP */
- title = screen->LoadImage(bmp->w, bmp->h, (Uint8 *)bmp->pixels, NULL);
+ title = screen->LoadImage(bmp);
SDL_FreeSurface(bmp);
return(title);
}
@@ -83,7 +83,8 @@ SDL_Texture *GetCIcon(FrameBuf *screen, short cicn_id)
}
SDL_RWclose(cicn_src);
- cicn = screen->LoadImage(w, h, pixels, mask);
+ sprintf(file, "Maelstrom_Icon#%d.bmp", cicn_id);
+ cicn = screen->LoadImage(w, h, pixels, mask, file);
delete[] pixels;
delete[] mask;
if ( cicn == NULL ) {
diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 3db20e24..17f4ae55 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -274,7 +274,7 @@ FrameBuf:: ScreenDump(const char *prefix, int x, int y, int w, int h)
}
SDL_Texture *
-FrameBuf:: LoadImage(int w, int h, Uint8 *pixels, Uint8 *mask)
+FrameBuf:: LoadImage(int w, int h, Uint8 *pixels, Uint8 *mask, const char *file)
{
SDL_Texture *texture;
Uint32 *artwork;
@@ -320,6 +320,9 @@ FrameBuf:: LoadImage(int w, int h, Uint8 *pixels, Uint8 *mask)
}
}
+SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(artwork, w, h, 32, w*4, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
+SDL_SaveBMP(surface, file);
+SDL_FreeSurface(surface);
texture = LoadImage(w, h, artwork);
if ( mask ) {
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
diff --git a/screenlib/SDL_FrameBuf.h b/screenlib/SDL_FrameBuf.h
index 55f50609..d632b617 100644
--- a/screenlib/SDL_FrameBuf.h
+++ b/screenlib/SDL_FrameBuf.h
@@ -240,7 +240,7 @@ class FrameBuf : public ErrorBase {
}
/* Load and convert an 8-bit image with the given mask */
- SDL_Texture *LoadImage(int w, int h, Uint8 *pixels, Uint8 *mask = NULL);
+ SDL_Texture *LoadImage(int w, int h, Uint8 *pixels, Uint8 *mask, const char *file);
SDL_Texture *LoadImage(int w, int h, Uint32 *pixels);
SDL_Texture *LoadImage(SDL_Surface *surface);
int GetImageWidth(SDL_Texture *image) {