diff options
author | Rogier Polak <rogier.l.a.polak@gmail.com> | 2007-03-18 13:54:40 +0000 |
---|---|---|
committer | Rogier Polak <rogier.l.a.polak@gmail.com> | 2007-03-18 13:54:40 +0000 |
commit | 1f1a5efaef0a10187592d29ea7b19e140e7a0196 (patch) | |
tree | 23c9fd117745d6387194e269b9182a9eaf65c3c7 /src/resources | |
parent | 89468a178c60ef4e4d774708a3f6cf10b35f4b42 (diff) | |
download | mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.gz mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.bz2 mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.tar.xz mana-1f1a5efaef0a10187592d29ea7b19e140e7a0196.zip |
Added --version to the arguments, deleted the 'pink-code'.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/image.cpp | 72 |
1 files changed, 4 insertions, 68 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 9398e06b..fed26851 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -99,66 +99,6 @@ Image* Image::load(void *buffer, unsigned int bufferSize, amask = 0xff000000; #endif - // Convert the image to a 32 bit software surface for processing - SDL_Surface *formatImage = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32, - rmask, gmask, bmask, amask); - - if (formatImage == NULL) { - logger->log("Error, image load failed: not enough memory"); - SDL_FreeSurface(tmpImage); - return NULL; - } - - SDL_Surface *image = SDL_ConvertSurface( - tmpImage, formatImage->format, SDL_SWSURFACE); - - SDL_FreeSurface(formatImage); - - if (image == NULL) { - logger->log("Error, image load failed: not enough memory"); - return NULL; - } - - bool hasPink = false; - bool hasAlpha = false; - int i; - Uint32 pink = SDL_MapRGB(image->format, 255, 0, 255); - - // Figure out whether the image has pink pixels - for (i = 0; i < image->w * image->h; ++i) - { - if (((Uint32*)image->pixels)[i] == pink) - { - hasPink = true; - break; - } - } - - // Figure out whether the image uses its alpha layer - for (i = 0; i < image->w * image->h; ++i) - { - Uint8 r, g, b, a; - SDL_GetRGBA( - ((Uint32*)image->pixels)[i], - image->format, - &r, &g, &b, &a); - - if (a != 255) - { - hasAlpha = true; - break; - } - } - - SDL_FreeSurface(image); - - if (hasPink && !hasAlpha) { - SDL_SetColorKey(tmpImage, SDL_SRCCOLORKEY, - SDL_MapRGB(tmpImage->format, 255, 0, 255)); - } else if (hasAlpha) { - SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); - } - #ifdef USE_OPENGL if (mUseOpenGL) { @@ -246,14 +186,10 @@ Image* Image::load(void *buffer, unsigned int bufferSize, } #endif - // Set color key and alpha blending optins, and convert the surface to the - // current display format - if (hasAlpha) { - image = SDL_DisplayFormatAlpha(tmpImage); - } - else { - image = SDL_DisplayFormat(tmpImage); - } + SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); + + SDL_Surface *image = SDL_DisplayFormatAlpha(tmpImage); + SDL_FreeSurface(tmpImage); if (image == NULL) { |