summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-02-22 21:32:50 (EST)
committer P. J. McDermott <pjm@nac.net>2013-02-22 22:11:03 (EST)
commit708db30ba67192e37462a849efe59a437b2d8319 (patch)
treef6d7931ac16f15af4bfbf940329aaa7ccef41d8a
parentaf991978ce1fade0f843a8ce97863adf1f95c260 (diff)
downloadoverworld-rpg-708db30ba67192e37462a849efe59a437b2d8319.zip
overworld-rpg-708db30ba67192e37462a849efe59a437b2d8319.tar.gz
overworld-rpg-708db30ba67192e37462a849efe59a437b2d8319.tar.bz2
Optionally list palette colors of loaded images.
-rw-r--r--configure.ac17
-rw-r--r--src/resources/image.c14
2 files changed, 28 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 2ed524a..f0921fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,7 @@ AC_ARG_ENABLE([debug-tmx],
[])
if test "x$enable_debug_tmx" = "xyes"; then
AC_DEFINE([DEBUG_TMX], [1],
- [Define to 1 to enable debug output from TMX parser])
+ [Define to 1 to enable debug output from TMX parser.])
fi
AC_ARG_ENABLE([debug-compression],
@@ -68,7 +68,7 @@ AC_ARG_ENABLE([debug-compression],
[])
if test "x$enable_debug_compression" = "xyes"; then
AC_DEFINE([DEBUG_COMPRESSION], [1],
- [Define to 1 to enable debug output from tile data inflation])
+ [Define to 1 to enable debug output from tile data inflation.])
fi
AC_ARG_ENABLE([debug-render],
@@ -79,7 +79,18 @@ AC_ARG_ENABLE([debug-render],
if test "x$enable_debug_render" = "xyes"; then
AC_DEFINE([DEBUG_RENDER], [1],
[Define to 1 to enable debug output from map layer blits and
- area rendering])
+ area rendering.])
+fi
+
+AC_ARG_ENABLE([debug-palettes],
+ [AC_HELP_STRING([--enable-debug-palettes],
+ [enable debug output with surface palette colors listings])],
+ [enable_debug_palettes=yes],
+ [])
+if test "x$enable_debug_palettes" = "xyes"; then
+ AC_DEFINE([DEBUG_PALETTES], [1],
+ [Define to 1 to enable debug output with surface palette colors
+ listings.])
fi
AC_CONFIG_FILES([Makefile])
diff --git a/src/resources/image.c b/src/resources/image.c
index cd2c317..ae7cd30 100644
--- a/src/resources/image.c
+++ b/src/resources/image.c
@@ -1,5 +1,6 @@
#include <SDL.h>
#include <SDL_image.h>
+#include <config.h>
#include "../logging.h"
#include "image.h"
#include "resource.h"
@@ -11,6 +12,9 @@ img_png_get(const char *path)
{
SDL_RWops *rwops;
struct image *img;
+#ifdef DEBUG_PALETTES
+ int i;
+#endif
img = (struct image *) resource_get(&img_res, path);
if (img != NULL) {
@@ -26,6 +30,16 @@ img_png_get(const char *path)
path, IMG_GetError());
}
+#ifdef DEBUG_PALETTES
+ for (i = 0; i < img->image->format->palette->ncolors; ++i) {
+ debug("Color %3.3d: 0x%2.2x%2.2x%2.2x",
+ i,
+ img->image->format->palette->colors[i].r,
+ img->image->format->palette->colors[i].g,
+ img->image->format->palette->colors[i].b);
+ }
+#endif
+
resource_use((struct resource *) img);
resource_add(&img_res, path, (struct resource *) img);