diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-20 00:18:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-20 00:18:04 +0300 |
commit | 30cd6bc597faefaf3775edc299671f17d6255a12 (patch) | |
tree | 0b060bd1c610ce646ad7989e8308c58e316d1e52 /src | |
parent | a786b399d67f8aac79ded71bd1f0e0999ce3a0bb (diff) | |
download | mv-30cd6bc597faefaf3775edc299671f17d6255a12.tar.gz mv-30cd6bc597faefaf3775edc299671f17d6255a12.tar.bz2 mv-30cd6bc597faefaf3775edc299671f17d6255a12.tar.xz mv-30cd6bc597faefaf3775edc299671f17d6255a12.zip |
fix normal dye in big endian systems.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/dye.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index e57f4afe2..acac5b9d9 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -510,13 +510,23 @@ void Dye::normalDye(uint32_t *pixels, const int bufSize) const for (uint32_t *p_end = pixels + bufSize; pixels != p_end; ++ pixels) { const uint32_t p = *pixels; - const int alpha = p & 255; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + const int alpha = p & 0xff000000; +#else + const int alpha = p & 0xff; +#endif if (!alpha) continue; int color[3]; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + color[0] = (p) & 255; + color[1] = (p >> 8) & 255; + color[2] = (p >> 16) & 255; +#else color[0] = (p >> 24) & 255; color[1] = (p >> 16) & 255; color[2] = (p >> 8) & 255; +#endif const int cmax = std::max(color[0], std::max(color[1], color[2])); if (cmax == 0) @@ -538,8 +548,13 @@ void Dye::normalDye(uint32_t *pixels, const int bufSize) const if (mDyePalettes[i - 1]) mDyePalettes[i - 1]->getColor(cmax, color); +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + *pixels = (color[0]) | (color[1] << 8) + | (color[2] << 16) | alpha; +#else *pixels = (color[0] << 24) | (color[1] << 16) | (color[2] << 8) | alpha; +#endif } } @@ -548,13 +563,23 @@ void Dye::normalOGLDye(uint32_t *pixels, const int bufSize) const for (uint32_t *p_end = pixels + bufSize; pixels != p_end; ++ pixels) { const uint32_t p = *pixels; - const int alpha = (p >> 24) & 255; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + const int alpha = p & 255; +#else + const int alpha = p & 0xff000000; +#endif if (!alpha) continue; int color[3]; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + color[0] = (p >> 24) & 255; + color[1] = (p >> 16) & 255; + color[2] = (p >> 8) & 255; +#else color[0] = (p) & 255; color[1] = (p >> 8) & 255; color[2] = (p >> 16) & 255; +#endif const int cmax = std::max(color[0], std::max(color[1], color[2])); if (cmax == 0) @@ -576,7 +601,12 @@ void Dye::normalOGLDye(uint32_t *pixels, const int bufSize) const if (mDyePalettes[i - 1]) mDyePalettes[i - 1]->getColor(cmax, color); +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + *pixels = (color[0] << 24) | (color[1] << 16) + | (color[2] << 8) | alpha; +#else *pixels = (color[0]) | (color[1] << 8) - | (color[2] << 16) | (alpha << 24); + | (color[2] << 16) | alpha; +#endif } } |