diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-07-16 18:18:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-07-16 18:18:22 +0300 |
commit | 07e401fb2335d2372a93f37317f144449f7e872b (patch) | |
tree | be531ab11e3f57705d1167f1f8d693906208b87a /src/resources/openglimagehelper.cpp | |
parent | 7cd117790755de302be9f750b95b5bd18a5636bd (diff) | |
download | plus-07e401fb2335d2372a93f37317f144449f7e872b.tar.gz plus-07e401fb2335d2372a93f37317f144449f7e872b.tar.bz2 plus-07e401fb2335d2372a93f37317f144449f7e872b.tar.xz plus-07e401fb2335d2372a93f37317f144449f7e872b.zip |
Add new dye type A.
Same as type S for colors + alpha channel.
Example:
equipment/feet/boots.png|A:#3c3c3cff,40332d40,4d4d4dff,5e4a3d40
here colors in format RRGGBBAA.
Diffstat (limited to 'src/resources/openglimagehelper.cpp')
-rw-r--r-- | src/resources/openglimagehelper.cpp | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 63c103e1f..aec68f32a 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -62,35 +62,59 @@ Resource *OpenGLImageHelper::load(SDL_RWops *rw, Dye const &dye) SDL_FreeSurface(tmpImage); uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); - DyePalette *pal = dye.getSPalete(); + int type = dye.getType(); - if (pal) + switch (type) { - for (uint32_t *p_end = pixels + surf->w * surf->h; - pixels != p_end; ++pixels) + case 1: { - uint8_t *p = reinterpret_cast<uint8_t *>(pixels); - const int alpha = *p & 255; - if (!alpha) - continue; - pal->replaceOGLColor(p); + DyePalette *pal = dye.getSPalete(); + + if (pal) + { + for (uint32_t *p_end = pixels + surf->w * surf->h; + pixels != p_end; ++pixels) + { + uint8_t *p = reinterpret_cast<uint8_t *>(pixels); + const int alpha = *p & 255; + if (!alpha) + continue; + pal->replaceSOGLColor(p); + } + } + break; } - } - else - { - for (uint32_t *p_end = pixels + surf->w * surf->h; - pixels != p_end; ++pixels) + case 2: + { + DyePalette *pal = dye.getAPalete(); + if (pal) + { + for (uint32_t *p_end = pixels + surf->w * surf->h; + pixels != p_end; ++pixels) + { + pal->replaceAOGLColor(reinterpret_cast<uint8_t *>(pixels)); + } + } + break; + } + case 0: + default: { - const uint32_t p = *pixels; - const int alpha = (p >> 24) & 255; - if (!alpha) - continue; - int v[3]; - v[0] = (p) & 255; - v[1] = (p >> 8) & 255; - v[2] = (p >> 16 ) & 255; - dye.update(v); - *pixels = (v[0]) | (v[1] << 8) | (v[2] << 16) | (alpha << 24); + for (uint32_t *p_end = pixels + surf->w * surf->h; + pixels != p_end; ++pixels) + { + const uint32_t p = *pixels; + const int alpha = (p >> 24) & 255; + if (!alpha) + continue; + int v[3]; + v[0] = (p) & 255; + v[1] = (p >> 8) & 255; + v[2] = (p >> 16 ) & 255; + dye.update(v); + *pixels = (v[0]) | (v[1] << 8) | (v[2] << 16) | (alpha << 24); + } + break; } } |