diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-16 13:16:00 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-16 13:16:00 +0000 |
commit | 81ca76356fe367d2b9467433a9acb732d6c9becb (patch) | |
tree | 564573b8cbf5bf50c06dea7c40111088654037e8 | |
parent | d3c7728804e762338669e6e9bd1b30d543ef8ee5 (diff) | |
download | mana-81ca76356fe367d2b9467433a9acb732d6c9becb.tar.gz mana-81ca76356fe367d2b9467433a9acb732d6c9becb.tar.bz2 mana-81ca76356fe367d2b9467433a9acb732d6c9becb.tar.xz mana-81ca76356fe367d2b9467433a9acb732d6c9becb.zip |
Sped up recoloring of transparent pixels.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/resources/image.cpp | 10 |
2 files changed, 6 insertions, 5 deletions
@@ -5,6 +5,7 @@ resource deletion by 30 seconds. * src/net/connection.cpp, src/resources/mapreader.cpp, src/net/network.cpp: Reduced noise in log file. + * src/resources/image.cpp: Sped up recoloring of transparent pixels. 2007-11-16 Eugenio Favalli <elvenprogrammer@gmail.com> 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); |