summaryrefslogtreecommitdiff
path: root/tools/dyecmd
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr>2010-05-22 15:49:19 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr>2010-05-27 02:20:44 +0200
commitaa0d2450a8e9188204d088e5c828aa1e636ba463 (patch)
treea9a7feff266bd2b7f886d438427c8f775c4ae1f5 /tools/dyecmd
parenta72030a4e8af2d60ccf574f224070805780e19ca (diff)
downloadMana-aa0d2450a8e9188204d088e5c828aa1e636ba463.tar.gz
Mana-aa0d2450a8e9188204d088e5c828aa1e636ba463.tar.bz2
Mana-aa0d2450a8e9188204d088e5c828aa1e636ba463.tar.xz
Mana-aa0d2450a8e9188204d088e5c828aa1e636ba463.zip
Fixed the dyecmd tool.
The bug was quite nasty to catch: The RGBA channels were inversed when writing the image, even if the code parts taken from the Mana Client were exactly copy/pasted. This was due to the fact that the client does an Image::load() call after recoloring which call SDL_displaySurface() that reverse the pixel order. I reversed then the recolored image pixel output to get back the right color for the image writer. Reviewed-by: Jaxad0127
Diffstat (limited to 'tools/dyecmd')
-rw-r--r--tools/dyecmd/src/dyecmd.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/dyecmd/src/dyecmd.cpp b/tools/dyecmd/src/dyecmd.cpp
index ebecf9f1..3ae963b7 100644
--- a/tools/dyecmd/src/dyecmd.cpp
+++ b/tools/dyecmd/src/dyecmd.cpp
@@ -23,8 +23,6 @@
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
-
-
#include "dye.h"
#include "imagewriter.h"
@@ -59,11 +57,15 @@ SDL_Surface* recolor(SDL_Surface* tmpImage, Dye* dye)
int alpha = *pixels & 255;
if (!alpha) continue;
int v[3];
- v[0] = (*pixels >> 24) & 255;
- v[1] = (*pixels >> 16) & 255;
- v[2] = (*pixels >> 8 ) & 255;
+ v[0] = (*pixels >> rgba.Rshift) & 255;
+ v[1] = (*pixels >> rgba.Gshift) & 255;
+ v[2] = (*pixels >> rgba.Bshift) & 255;
dye->update(v);
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*pixels = (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | alpha;
+#else
+ *pixels = v[0] | (v[1] << 8) | (v[2] << 16) | (alpha << 24);
+#endif
}
return surf;