diff --git a/src/Makefile.am b/src/Makefile.am index ce31093..d0b5716 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,8 @@ gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ settingsdialog.cpp sfontplus.cpp surfacecollection.cpp surface.cpp \ textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp \ utilities.cpp wallpaperdialog.cpp \ - browsedialog.cpp buttonbox.cpp dialog.cpp + browsedialog.cpp buttonbox.cpp dialog.cpp \ + imageio.cpp noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \ filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h \ @@ -23,7 +24,8 @@ noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \ messagebox.h selector.h settingsdialog.h \ sfontplus.h surfacecollection.h surface.h textdialog.h textmanualdialog.h \ touchscreen.h translator.h utilities.h wallpaperdialog.h \ - browsedialog.h buttonbox.h dialog.h + browsedialog.h buttonbox.h dialog.h \ + imageio.h AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@ diff --git a/src/imageio.cpp b/src/imageio.cpp new file mode 100644 index 0000000..aeebbcb --- /dev/null +++ b/src/imageio.cpp @@ -0,0 +1,8 @@ +#include "imageio.h" + +#include + +SDL_Surface *loadPNG(const std::string &path) +{ + return IMG_Load(path.c_str()); +} diff --git a/src/imageio.h b/src/imageio.h new file mode 100644 index 0000000..3e4e48f --- /dev/null +++ b/src/imageio.h @@ -0,0 +1,10 @@ +#ifndef IMAGEIO_H +#define IMAGEIO_H + +#include + +struct SDL_Surface; + +SDL_Surface *loadPNG(const std::string &path); + +#endif diff --git a/src/sfontplus.cpp b/src/sfontplus.cpp index 765ec99..8ac44bb 100644 --- a/src/sfontplus.cpp +++ b/src/sfontplus.cpp @@ -1,7 +1,8 @@ #include "sfontplus.h" +#include "imageio.h" + #include -#include #include using namespace std; @@ -63,7 +64,7 @@ bool SFontPlus::utf8Code(unsigned char c) { } void SFontPlus::initFont(const string &font, const string &characters) { - SDL_Surface *buf = IMG_Load(font.c_str()); + SDL_Surface *buf = loadPNG(font); if (buf!=NULL) { initFont( SDL_DisplayFormatAlpha(buf), characters ); SDL_FreeSurface(buf); diff --git a/src/surface.cpp b/src/surface.cpp index 4947f67..e5dc46e 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -18,15 +18,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "surface.h" +#include "imageio.h" +#include "utilities.h" +#include "debug.h" + #include #include using namespace std; -#include "surface.h" -#include "utilities.h" -#include "debug.h" - RGBAColor strtorgba(const string &strColor) { RGBAColor c = {0,0,0,255}; c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 0, 255 ); @@ -124,7 +125,7 @@ void Surface::load(const string &img, bool alpha, const string &skin) { skinpath = img; } - SDL_Surface *buf = IMG_Load(skinpath.c_str()); + SDL_Surface *buf = loadPNG(skinpath); if (buf!=NULL) { if (alpha) raw = SDL_DisplayFormatAlpha(buf); diff --git a/src/surface.h b/src/surface.h index e0f3478..2fdb047 100644 --- a/src/surface.h +++ b/src/surface.h @@ -20,9 +20,8 @@ #ifndef SURFACE_H #define SURFACE_H -#include #include -#include +#include #include "asfont.h" diff --git a/src/surfacecollection.cpp b/src/surfacecollection.cpp index bcd8a51..f9c22a3 100644 --- a/src/surfacecollection.cpp +++ b/src/surfacecollection.cpp @@ -23,6 +23,8 @@ #include "utilities.h" #include "debug.h" +#include + using std::endl; using std::string;