summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-18 22:16:51 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-18 22:16:51 +0000
commit1db1974435a6c9dff4908fefb6fe4fd093fc431f (patch)
treeeffef986bbdfcf800c829647b19c81e6798c6763 /src
parent1f1a5efaef0a10187592d29ea7b19e140e7a0196 (diff)
downloadmana-client-1db1974435a6c9dff4908fefb6fe4fd093fc431f.tar.gz
mana-client-1db1974435a6c9dff4908fefb6fe4fd093fc431f.tar.bz2
mana-client-1db1974435a6c9dff4908fefb6fe4fd093fc431f.tar.xz
mana-client-1db1974435a6c9dff4908fefb6fe4fd093fc431f.zip
Added man page by Patrick Matthäi and restored alpha layer check.
Diffstat (limited to 'src')
-rw-r--r--src/resources/image.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index fed26851..a7c81574 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -99,6 +99,28 @@ Image* Image::load(void *buffer, unsigned int bufferSize,
amask = 0xff000000;
#endif
+ bool hasAlpha = false;
+
+ // Figure out whether the image uses its alpha layer
+ for (int i = 0; i < tmpImage->w * tmpImage->h; ++i)
+ {
+ Uint8 r, g, b, a;
+ SDL_GetRGBA(
+ ((Uint32*) tmpImage->pixels)[i],
+ tmpImage->format,
+ &r, &g, &b, &a);
+
+ if (a != 255)
+ {
+ hasAlpha = true;
+ break;
+ }
+ }
+
+ if (hasAlpha) {
+ SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
+ }
+
#ifdef USE_OPENGL
if (mUseOpenGL)
{
@@ -186,10 +208,15 @@ Image* Image::load(void *buffer, unsigned int bufferSize,
}
#endif
- SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
-
- SDL_Surface *image = SDL_DisplayFormatAlpha(tmpImage);
+ SDL_Surface *image;
+ // Convert the surface to the current display format
+ if (hasAlpha) {
+ image = SDL_DisplayFormatAlpha(tmpImage);
+ }
+ else {
+ image = SDL_DisplayFormat(tmpImage);
+ }
SDL_FreeSurface(tmpImage);
if (image == NULL) {