summaryrefslogtreecommitdiff
path: root/src/resources/image.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-16 13:16:00 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-16 13:16:00 +0000
commit81ca76356fe367d2b9467433a9acb732d6c9becb (patch)
tree564573b8cbf5bf50c06dea7c40111088654037e8 /src/resources/image.cpp
parentd3c7728804e762338669e6e9bd1b30d543ef8ee5 (diff)
downloadmana-client-81ca76356fe367d2b9467433a9acb732d6c9becb.tar.gz
mana-client-81ca76356fe367d2b9467433a9acb732d6c9becb.tar.bz2
mana-client-81ca76356fe367d2b9467433a9acb732d6c9becb.tar.xz
mana-client-81ca76356fe367d2b9467433a9acb732d6c9becb.zip
Sped up recoloring of transparent pixels.
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r--src/resources/image.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index fb441bbf..d0dae462 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -113,16 +113,16 @@ Resource *Image::load(void *buffer, unsigned bufferSize, Dye const &dye)
SDL_FreeSurface(tmpImage);
Uint32 *pixels = static_cast< Uint32 * >(surf->pixels);
- for (int i = 0, i_end = surf->w * surf->h; i != i_end; ++i)
+ for (Uint32 *p_end = pixels + surf->w * surf->h; pixels != p_end; ++pixels)
{
- int v[4];
+ 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[3] = (*pixels ) & 255;
dye.update(v);
- *pixels = (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | v[3];
- ++pixels;
+ *pixels = (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | alpha;
}
Image *image = load(surf);