diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-11-02 00:30:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-11-02 00:30:15 +0300 |
commit | 3f04f19a4e30eadf18e2aa18df01655de58a1ffa (patch) | |
tree | 367852ed3d5600565949a749e8b40e10ca1253c8 | |
parent | 2d666d9a3b1bc0aeede357882e054b6afd17a9f1 (diff) | |
download | manaplus-3f04f19a4e30eadf18e2aa18df01655de58a1ffa.tar.gz manaplus-3f04f19a4e30eadf18e2aa18df01655de58a1ffa.tar.bz2 manaplus-3f04f19a4e30eadf18e2aa18df01655de58a1ffa.tar.xz manaplus-3f04f19a4e30eadf18e2aa18df01655de58a1ffa.zip |
fix images in did you know dialog.
-rw-r--r-- | src/debug.h | 2 | ||||
-rw-r--r-- | src/resources/imagehelper.cpp | 18 | ||||
-rw-r--r-- | src/utils/sdlcheckutils.cpp | 6 | ||||
-rw-r--r-- | src/utils/sdlcheckutils.h | 3 |
4 files changed, 24 insertions, 5 deletions
diff --git a/src/debug.h b/src/debug.h index db1989b77..bd304c4bd 100644 --- a/src/debug.h +++ b/src/debug.h @@ -44,6 +44,7 @@ #ifdef DEBUG_SDL_SURFACES #define MIMG_LoadPNG_RW(src) FakeIMG_LoadPNG_RW(src, __FILE__, __LINE__) +#define MIMG_LoadJPG_RW(src) FakeIMG_LoadJPG_RW(src, __FILE__, __LINE__) #define MSDL_FreeSurface(s) FakeSDL_FreeSurface(s, __FILE__, __LINE__) #define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a) \ FakeSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a, __FILE__, __LINE__) @@ -60,6 +61,7 @@ #else // ENABLE_SDL_DEBUG #define MIMG_LoadPNG_RW(src) IMG_LoadPNG_RW(src) +#define MIMG_LoadJPG_RW(src) IMG_LoadJPG_RW(src) #define MSDL_FreeSurface(surface) SDL_FreeSurface(surface) #define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a) \ SDL_CreateRGBSurface(flags, w, h, d, r, g, b, a) diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index dbbe21769..51ca0d44e 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -120,13 +120,21 @@ SDL_Surface *ImageHelper::loadPng(SDL_RWops *const rw) if (!rw) return nullptr; - if (!IMG_isPNG(rw)) + if (IMG_isPNG(rw)) { - logger->log("Error, image is not png"); + SDL_Surface *const tmpImage = MIMG_LoadPNG_RW(rw); SDL_RWclose(rw); - return nullptr; + return tmpImage; + } + + if (IMG_isJPG(rw)) + { + SDL_Surface *const tmpImage = MIMG_LoadJPG_RW(rw); + SDL_RWclose(rw); + return tmpImage; } - SDL_Surface *const tmpImage = MIMG_LoadPNG_RW(rw); + + logger->log("Error, image is not png"); SDL_RWclose(rw); - return tmpImage; + return nullptr; } diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp index 3810672d9..7140e44fe 100644 --- a/src/utils/sdlcheckutils.cpp +++ b/src/utils/sdlcheckutils.cpp @@ -138,6 +138,12 @@ SDL_Surface *FakeIMG_LoadPNG_RW(SDL_RWops *const src, const char *const file, return addSurface("IMG_LoadPNG_RW", IMG_LoadPNG_RW(src), file, line); } +SDL_Surface *FakeIMG_LoadJPG_RW(SDL_RWops *const src, const char *const file, + const unsigned line) +{ + return addSurface("IMG_LoadJPG_RW", IMG_LoadJPG_RW(src), file, line); +} + SDL_Surface *FakeIMG_Load(const char *name, const char *const file, const unsigned line) { diff --git a/src/utils/sdlcheckutils.h b/src/utils/sdlcheckutils.h index b1f1a0821..a2f9bb90a 100644 --- a/src/utils/sdlcheckutils.h +++ b/src/utils/sdlcheckutils.h @@ -35,6 +35,9 @@ struct SDL_Surface; SDL_Surface *FakeIMG_LoadPNG_RW(SDL_RWops *const src, const char *const file, const unsigned line); +SDL_Surface *FakeIMG_LoadJPG_RW(SDL_RWops *const src, const char *const file, + const unsigned line); + void FakeSDL_FreeSurface(SDL_Surface *const surface, const char *const file, const unsigned line); |