summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map.cpp14
-rw-r--r--src/resources/image.cpp4
-rw-r--r--src/resources/image.h19
3 files changed, 28 insertions, 9 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 66bdbd4bc..fa9d014df 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1816,10 +1816,18 @@ void Map::reduce()
Image *img = layer->mTiles[x + y * layer->mWidth];
if (img)
{
- img->setAlphaVisible(true);
- if (img->mBounds.w > 32 || img->mBounds.h > 32)
+ if (img->hasAlphaChannel() && img->isAlphaCalculated())
+ {
+ if (!img->isAlphaVisible())
+ {
+ dontHaveAlpha = true;
+ img->setAlphaVisible(false);
+ }
+ }
+ else if (img->mBounds.w > 32 || img->mBounds.h > 32)
{
correct = false;
+ img->setAlphaVisible(true);
break;
}
else if (!img->isHasAlphaChannel())
@@ -1832,6 +1840,7 @@ void Map::reduce()
Uint8 *arr = img->SDLgetAlphaChannel();
if (!arr)
continue;
+
bool bad(false);
bool stop(false);
int width;
@@ -1868,6 +1877,7 @@ void Map::reduce()
img->setAlphaVisible(true);
}
}
+ img->setAlphaCalculated(true);
}
}
if (!correct || !dontHaveAlpha)
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index fdcf210c3..29e89d26e 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -54,7 +54,8 @@ Image::Image(SDL_Surface *image, bool hasAlphaChannel, Uint8 *alphaChannel):
mHasAlphaChannel(hasAlphaChannel),
mSDLSurface(image),
mAlphaChannel(alphaChannel),
- mIsAlphaVisible(hasAlphaChannel)
+ mIsAlphaVisible(hasAlphaChannel),
+ mIsAlphaCalculated(false)
{
#ifdef USE_OPENGL
mGLImage = 0;
@@ -90,6 +91,7 @@ Image::Image(GLuint glimage, int width, int height,
mAlphaChannel(0),
mUseAlphaCache(false),
mIsAlphaVisible(true),
+ mIsAlphaCalculated(false),
mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight)
diff --git a/src/resources/image.h b/src/resources/image.h
index c4b0cf540..718301f81 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -223,21 +223,27 @@ class Image : public Resource
void setAlphaVisible(bool b)
{ mIsAlphaVisible = b; }
+ bool isAlphaCalculated()
+ { return mIsAlphaCalculated; }
+
+ void setAlphaCalculated(bool b)
+ { mIsAlphaCalculated = b; }
+
SDL_Rect mBounds;
protected:
- // -----------------------
- // Generic protected members
- // -----------------------
+ // -----------------------
+ // Generic protected members
+ // -----------------------
bool mLoaded;
float mAlpha;
bool mHasAlphaChannel;
- // -----------------------
- // SDL protected members
- // -----------------------
+ // -----------------------
+ // SDL protected members
+ // -----------------------
/** SDL Constructor */
Image(SDL_Surface *image, bool hasAlphaChannel = false,
@@ -257,6 +263,7 @@ class Image : public Resource
bool mUseAlphaCache;
bool mIsAlphaVisible;
+ bool mIsAlphaCalculated;
static bool mEnableAlphaCache;
static bool mEnableAlpha;