diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-06-17 20:13:48 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-06-17 20:13:48 +0300 |
commit | c2efedab22275302f0a10cc197424d345a021d18 (patch) | |
tree | 7488abbb3655451a3f6a1621e0708f72011af5f6 /src/resources/sdlimagehelper.cpp | |
parent | 79aba82be3de5b6b571e2f59f7a34ded4b03160f (diff) | |
download | mv-c2efedab22275302f0a10cc197424d345a021d18.tar.gz mv-c2efedab22275302f0a10cc197424d345a021d18.tar.bz2 mv-c2efedab22275302f0a10cc197424d345a021d18.tar.xz mv-c2efedab22275302f0a10cc197424d345a021d18.zip |
Replace SDL int types to C++ types.
Diffstat (limited to 'src/resources/sdlimagehelper.cpp')
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index a416a35d2..6c281514e 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -65,15 +65,15 @@ Resource *SDLImageHelper::load(SDL_RWops *rw, Dye const &dye) surf = SDL_ConvertSurface(tmpImage, &rgba, SDL_SWSURFACE); SDL_FreeSurface(tmpImage); - Uint32 *pixels = static_cast<Uint32 *>(surf->pixels); + uint32_t *pixels = static_cast<uint32_t *>(surf->pixels); DyePalette *pal = dye.getSPalete(); if (pal) { - for (Uint32 *p_end = pixels + surf->w * surf->h; + for (uint32_t *p_end = pixels + surf->w * surf->h; pixels != p_end; ++pixels) { - Uint8 *p = reinterpret_cast<Uint8 *>(pixels); + uint8_t *p = reinterpret_cast<uint8_t *>(pixels); const int alpha = *p & 255; if (!alpha) continue; @@ -82,10 +82,10 @@ Resource *SDLImageHelper::load(SDL_RWops *rw, Dye const &dye) } else { - for (Uint32 *p_end = pixels + surf->w * surf->h; + for (uint32_t *p_end = pixels + surf->w * surf->h; pixels != p_end; ++pixels) { - const Uint32 p = *pixels; + const uint32_t p = *pixels; const int alpha = p & 255; if (!alpha) continue; @@ -121,23 +121,23 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *tmpImage, float alpha) const int sz = tmpImage->w * tmpImage->h; // The alpha channel to be filled with alpha values - Uint8 *alphaChannel = new Uint8[sz]; + uint8_t *alphaChannel = new uint8_t[sz]; const SDL_PixelFormat * const fmt = tmpImage->format; if (fmt->Amask) { for (int i = 0; i < sz; ++ i) { - Uint32 c = (static_cast<Uint32*>(tmpImage->pixels))[i]; + uint32_t c = (static_cast<uint32_t*>(tmpImage->pixels))[i]; unsigned v = (c & fmt->Amask) >> fmt->Ashift; - Uint8 a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1))); + uint8_t a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1))); - Uint8 a2 = static_cast<Uint8>(static_cast<float>(a) * alpha); + uint8_t a2 = static_cast<uint8_t>(static_cast<float>(a) * alpha); c &= ~fmt->Amask; c |= ((a2 >> fmt->Aloss) << fmt->Ashift & fmt->Amask); - (static_cast<Uint32*>(tmpImage->pixels))[i] = c; + (static_cast<uint32_t*>(tmpImage->pixels))[i] = c; if (a != 255) hasAlpha = true; @@ -206,7 +206,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) const int sz = tmpImage->w * tmpImage->h; // The alpha channel to be filled with alpha values - Uint8 *alphaChannel = new Uint8[sz]; + uint8_t *alphaChannel = new uint8_t[sz]; // Figure out whether the image uses its alpha layer if (!tmpImage->format->palette) @@ -216,9 +216,9 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) { for (int i = 0; i < sz; ++ i) { - unsigned v = ((static_cast<Uint32*>(tmpImage->pixels))[i] + unsigned v = ((static_cast<uint32_t*>(tmpImage->pixels))[i] & fmt->Amask) >> fmt->Ashift; - Uint8 a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1))); + uint8_t a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1))); if (a != 255) hasAlpha = true; |