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 | |
parent | 79aba82be3de5b6b571e2f59f7a34ded4b03160f (diff) | |
download | plus-c2efedab22275302f0a10cc197424d345a021d18.tar.gz plus-c2efedab22275302f0a10cc197424d345a021d18.tar.bz2 plus-c2efedab22275302f0a10cc197424d345a021d18.tar.xz plus-c2efedab22275302f0a10cc197424d345a021d18.zip |
Replace SDL int types to C++ types.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/dye.cpp | 4 | ||||
-rw-r--r-- | src/resources/dye.h | 4 | ||||
-rw-r--r-- | src/resources/image.cpp | 18 | ||||
-rw-r--r-- | src/resources/image.h | 6 | ||||
-rw-r--r-- | src/resources/imagewriter.cpp | 2 | ||||
-rw-r--r-- | src/resources/openglimagehelper.cpp | 12 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 26 | ||||
-rw-r--r-- | src/resources/subimage.cpp | 8 |
8 files changed, 40 insertions, 40 deletions
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 78ad8137a..59d8f18df 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -205,7 +205,7 @@ void DyePalette::getColor(double intensity, int color[3]) const color[2] = static_cast<int>(rest * b1 + intensity * b2); } -void DyePalette::replaceColor(Uint8 *color) const +void DyePalette::replaceColor(uint8_t *color) const { std::vector<Color>::const_iterator it = mColors.begin(); std::vector<Color>::const_iterator it_end = mColors.end(); @@ -228,7 +228,7 @@ void DyePalette::replaceColor(Uint8 *color) const } } -void DyePalette::replaceOGLColor(Uint8 *color) const +void DyePalette::replaceOGLColor(uint8_t *color) const { std::vector<Color>::const_iterator it = mColors.begin(); std::vector<Color>::const_iterator it_end = mColors.end(); diff --git a/src/resources/dye.h b/src/resources/dye.h index b238f65fb..26135d82e 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -61,9 +61,9 @@ class DyePalette */ void getColor(double intensity, int color[3]) const; - void replaceColor(Uint8 *color) const; + void replaceColor(uint8_t *color) const; - void replaceOGLColor(Uint8 *color) const; + void replaceOGLColor(uint8_t *color) const; private: struct Color diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 3c5a2a97e..a4be43e4e 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -46,7 +46,7 @@ #include "debug.h" -Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel): +Image::Image(SDL_Surface *image, bool hasAlphaChannel0, uint8_t *alphaChannel): mAlpha(1.0f), mHasAlphaChannel(hasAlphaChannel0), mSDLSurface(image), @@ -67,8 +67,8 @@ Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel): if (mSDLSurface) { - mBounds.w = static_cast<Uint16>(mSDLSurface->w); - mBounds.h = static_cast<Uint16>(mSDLSurface->h); + mBounds.w = static_cast<uint16_t>(mSDLSurface->w); + mBounds.h = static_cast<uint16_t>(mSDLSurface->h); mLoaded = true; } @@ -97,8 +97,8 @@ Image::Image(GLuint glimage, int width, int height, { mBounds.x = 0; mBounds.y = 0; - mBounds.w = static_cast<Uint16>(width); - mBounds.h = static_cast<Uint16>(height); + mBounds.w = static_cast<uint16_t>(width); + mBounds.h = static_cast<uint16_t>(height); if (mGLImage) { @@ -265,16 +265,16 @@ void Image::setAlpha(float alpha) for (int i = i1; i <= i2; i++) { // Only change the pixel if it was visible at load time... - Uint8 sourceAlpha = mAlphaChannel[i]; + uint8_t sourceAlpha = mAlphaChannel[i]; if (sourceAlpha > 0) { - Uint8 a = static_cast<Uint8>( + uint8_t a = static_cast<uint8_t>( static_cast<float>(sourceAlpha) * mAlpha); - Uint32 c = (static_cast<Uint32*>(mSDLSurface->pixels))[i]; + uint32_t c = (static_cast<uint32_t*>(mSDLSurface->pixels))[i]; c &= ~fmt->Amask; c |= ((a >> fmt->Aloss) << fmt->Ashift & fmt->Amask); - (static_cast<Uint32*>(mSDLSurface->pixels))[i] = c; + (static_cast<uint32_t*>(mSDLSurface->pixels))[i] = c; } } diff --git a/src/resources/image.h b/src/resources/image.h index c7d2657bd..59178cca6 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -133,7 +133,7 @@ class Image : public Resource /** * Get the alpha Channel of a SDL surface. */ - Uint8 *SDLgetAlphaChannel() const + uint8_t *SDLgetAlphaChannel() const { return mAlphaChannel; } void SDLCleanCache(); @@ -183,14 +183,14 @@ class Image : public Resource /** SDL Constructor */ Image(SDL_Surface *image, bool hasAlphaChannel = false, - Uint8 *alphaChannel = nullptr); + uint8_t *alphaChannel = nullptr); SDL_Surface *getByAlpha(float alpha); SDL_Surface *mSDLSurface; /** Alpha Channel pointer used for 32bit based SDL surfaces */ - Uint8 *mAlphaChannel; + uint8_t *mAlphaChannel; std::map<float, SDL_Surface*> mAlphaCache; diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 9501c98a5..f452a9050 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -103,7 +103,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) for (int i = 0; i < surface->h; i++) { - row_pointers[i] = static_cast<png_bytep>(static_cast<Uint8 *>( + row_pointers[i] = static_cast<png_bytep>(static_cast<uint8_t *>( surface->pixels)) + i * surface->pitch; } diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index db75a7b0c..7606b9ec8 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -61,15 +61,15 @@ Resource *OpenGLImageHelper::load(SDL_RWops *rw, Dye const &dye) SDL_Surface *surf = convertTo32Bit(tmpImage); 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; @@ -78,10 +78,10 @@ Resource *OpenGLImageHelper::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 >> 24) & 255; if (!alpha) continue; @@ -154,7 +154,7 @@ Image *OpenGLImageHelper::_GLload(SDL_Surface *tmpImage) SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE); // Determine 32-bit masks based on byte order - Uint32 rmask, gmask, bmask, amask; + uint32_t rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0xff000000; gmask = 0x00ff0000; 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; diff --git a/src/resources/subimage.cpp b/src/resources/subimage.cpp index 895bdc9a7..bc9b0794f 100644 --- a/src/resources/subimage.cpp +++ b/src/resources/subimage.cpp @@ -57,8 +57,8 @@ SubImage::SubImage(Image *parent, SDL_Surface *image, // Set up the rectangle. mBounds.x = static_cast<short>(x); mBounds.y = static_cast<short>(y); - mBounds.w = static_cast<Uint16>(width); - mBounds.h = static_cast<Uint16>(height); + mBounds.w = static_cast<uint16_t>(width); + mBounds.h = static_cast<uint16_t>(height); if (mParent) { mInternalBounds.x = mParent->mBounds.x; @@ -89,8 +89,8 @@ SubImage::SubImage(Image *parent, GLuint image, // Set up the rectangle. mBounds.x = static_cast<short>(x); mBounds.y = static_cast<short>(y); - mBounds.w = static_cast<Uint16>(width); - mBounds.h = static_cast<Uint16>(height); + mBounds.w = static_cast<uint16_t>(width); + mBounds.h = static_cast<uint16_t>(height); if (mParent) { mInternalBounds.x = mParent->mBounds.x; |