summaryrefslogtreecommitdiff
path: root/tools/dyecmd/src
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/src
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/src')
-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;