From aa0d2450a8e9188204d088e5c828aa1e636ba463 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sat, 22 May 2010 15:49:19 +0200 Subject: 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 --- tools/dyecmd/src/dyecmd.cpp | 12 +++++++----- 1 file 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 #include - - #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; -- cgit v1.2.3-70-g09d2