diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-13 14:10:15 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-13 14:10:15 +0000 |
commit | 821732ebbc2760ec98e0097f38a962c67285d421 (patch) | |
tree | 2e4fbb5b22108bf6d71011541acb927e9f633a5e /src/resources/image.cpp | |
parent | 6c5351a2cbe2655a6b255cb882ade9e6f988c0ea (diff) | |
download | mana-821732ebbc2760ec98e0097f38a962c67285d421.tar.gz mana-821732ebbc2760ec98e0097f38a962c67285d421.tar.bz2 mana-821732ebbc2760ec98e0097f38a962c67285d421.tar.xz mana-821732ebbc2760ec98e0097f38a962c67285d421.zip |
Allow preservation of alpha channel when loading image resources, which is used
to load alpha blended mouse cursor, which is now drawn instead of using the
system cursor.
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r-- | src/resources/image.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 15ef6708..f84826bb 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -26,6 +26,7 @@ #include <iostream> #include <SDL_image.h> #include "../graphic/graphic.h" +#include "resourcemanager.h" Image::Image(SDL_Surface *image): image(image) @@ -37,7 +38,7 @@ Image::~Image() unload(); } -Image* Image::load(const std::string &filePath) +Image* Image::load(const std::string &filePath, int flags) { #ifdef __DEBUG std::cout << "Image::load(" << filePath << ")\n"; @@ -46,7 +47,13 @@ Image* Image::load(const std::string &filePath) SDL_Surface *tmpImage = IMG_Load(filePath.c_str()); SDL_SetColorKey(tmpImage, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(tmpImage->format, 255, 0, 255)); - SDL_Surface *image = SDL_DisplayFormat(tmpImage); + SDL_Surface *image = NULL; + if (flags & IMG_ALPHA) { + image = SDL_DisplayFormatAlpha(tmpImage); + } + else { + image = SDL_DisplayFormat(tmpImage); + } SDL_FreeSurface(tmpImage); // Check if the file was opened and return the appropriate value. |