From c2efedab22275302f0a10cc197424d345a021d18 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 17 Jun 2012 20:13:48 +0300 Subject: Replace SDL int types to C++ types. --- src/resources/dye.cpp | 4 ++-- src/resources/dye.h | 4 ++-- src/resources/image.cpp | 18 +++++++++--------- src/resources/image.h | 6 +++--- src/resources/imagewriter.cpp | 2 +- src/resources/openglimagehelper.cpp | 12 ++++++------ src/resources/sdlimagehelper.cpp | 26 +++++++++++++------------- src/resources/subimage.cpp | 8 ++++---- 8 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src/resources') 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(rest * b1 + intensity * b2); } -void DyePalette::replaceColor(Uint8 *color) const +void DyePalette::replaceColor(uint8_t *color) const { std::vector::const_iterator it = mColors.begin(); std::vector::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::const_iterator it = mColors.begin(); std::vector::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(mSDLSurface->w); - mBounds.h = static_cast(mSDLSurface->h); + mBounds.w = static_cast(mSDLSurface->w); + mBounds.h = static_cast(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(width); - mBounds.h = static_cast(height); + mBounds.w = static_cast(width); + mBounds.h = static_cast(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_t a = static_cast( static_cast(sourceAlpha) * mAlpha); - Uint32 c = (static_cast(mSDLSurface->pixels))[i]; + uint32_t c = (static_cast(mSDLSurface->pixels))[i]; c &= ~fmt->Amask; c |= ((a >> fmt->Aloss) << fmt->Ashift & fmt->Amask); - (static_cast(mSDLSurface->pixels))[i] = c; + (static_cast(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 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(static_cast( + row_pointers[i] = static_cast(static_cast( 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(surf->pixels); + uint32_t *pixels = static_cast(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(pixels); + uint8_t *p = reinterpret_cast(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(surf->pixels); + uint32_t *pixels = static_cast(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(pixels); + uint8_t *p = reinterpret_cast(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(tmpImage->pixels))[i]; + uint32_t c = (static_cast(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(static_cast(a) * alpha); + uint8_t a2 = static_cast(static_cast(a) * alpha); c &= ~fmt->Amask; c |= ((a2 >> fmt->Aloss) << fmt->Ashift & fmt->Amask); - (static_cast(tmpImage->pixels))[i] = c; + (static_cast(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(tmpImage->pixels))[i] + unsigned v = ((static_cast(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(x); mBounds.y = static_cast(y); - mBounds.w = static_cast(width); - mBounds.h = static_cast(height); + mBounds.w = static_cast(width); + mBounds.h = static_cast(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(x); mBounds.y = static_cast(y); - mBounds.w = static_cast(width); - mBounds.h = static_cast(height); + mBounds.w = static_cast(width); + mBounds.h = static_cast(height); if (mParent) { mInternalBounds.x = mParent->mBounds.x; -- cgit v1.2.3-60-g2f50