diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-10 01:08:32 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-10 01:08:32 +0300 |
commit | bff595c13f2e6bc98857d6f5d02ec79eefb751cc (patch) | |
tree | 17e38c6b9615a49035dc933e6312266eabf7b89d /src | |
parent | 3e9d70d40bfd0205ffaf4db268e6c4a908fc36e9 (diff) | |
download | manaplus-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.tar.gz manaplus-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.tar.bz2 manaplus-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.tar.xz manaplus-bff595c13f2e6bc98857d6f5d02ec79eefb751cc.zip |
Improve image loading speed in Software mode.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/image.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 4a89ae636..e9260071f 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -555,35 +555,38 @@ Image *Image::_SDLload(SDL_Surface *tmpImage) converted = true; } + const int sz = tmpImage->w * tmpImage->h; // Figure out whether the image uses its alpha layer if (tmpImage->format->palette == NULL) { const SDL_PixelFormat * const fmt = tmpImage->format; - for (int i = 0; i < tmpImage->w * tmpImage->h; ++ i) + if (fmt->Amask) { - Uint8 a; - if (fmt->Amask) + for (int i = 0; i < sz; ++ i) { unsigned v = ((static_cast<Uint32*>(tmpImage->pixels))[i] & fmt->Amask) >> fmt->Ashift; - a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1))); - } - else - { - a = SDL_ALPHA_OPAQUE; - } + Uint8 a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1))); - if (a != 255) - hasAlpha = true; + if (a != 255) + hasAlpha = true; - alphaChannel[i] = a; + alphaChannel[i] = a; + } + } + else + { + if (SDL_ALPHA_OPAQUE != 255) + hasAlpha = true; + for (int i = 0; i < sz; ++ i) + alphaChannel[i] = SDL_ALPHA_OPAQUE; } } else { if (SDL_ALPHA_OPAQUE != 255) hasAlpha = true; - for (int i = 0; i < tmpImage->w * tmpImage->h; ++ i) + for (int i = 0; i < sz; ++ i) alphaChannel[i] = SDL_ALPHA_OPAQUE; } |