mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-23 00:02:48 +02:00
Isolate all PNG loading in a separate source/header.
This is in preparation of replacing SDL_image with direct use of libpng.
This commit is contained in:
parent
c22cc4d663
commit
e6be835038
@ -11,7 +11,8 @@ gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \
|
|||||||
settingsdialog.cpp sfontplus.cpp surfacecollection.cpp surface.cpp \
|
settingsdialog.cpp sfontplus.cpp surfacecollection.cpp surface.cpp \
|
||||||
textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp \
|
textdialog.cpp textmanualdialog.cpp touchscreen.cpp translator.cpp \
|
||||||
utilities.cpp wallpaperdialog.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 \
|
noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h FastDelegate.h \
|
||||||
filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.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 \
|
messagebox.h selector.h settingsdialog.h \
|
||||||
sfontplus.h surfacecollection.h surface.h textdialog.h textmanualdialog.h \
|
sfontplus.h surfacecollection.h surface.h textdialog.h textmanualdialog.h \
|
||||||
touchscreen.h translator.h utilities.h wallpaperdialog.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@
|
AM_CFLAGS= @CFLAGS@ @SDL_CFLAGS@
|
||||||
|
|
||||||
|
8
src/imageio.cpp
Normal file
8
src/imageio.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "imageio.h"
|
||||||
|
|
||||||
|
#include <SDL_image.h>
|
||||||
|
|
||||||
|
SDL_Surface *loadPNG(const std::string &path)
|
||||||
|
{
|
||||||
|
return IMG_Load(path.c_str());
|
||||||
|
}
|
10
src/imageio.h
Normal file
10
src/imageio.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef IMAGEIO_H
|
||||||
|
#define IMAGEIO_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct SDL_Surface;
|
||||||
|
|
||||||
|
SDL_Surface *loadPNG(const std::string &path);
|
||||||
|
|
||||||
|
#endif
|
@ -1,7 +1,8 @@
|
|||||||
#include "sfontplus.h"
|
#include "sfontplus.h"
|
||||||
|
|
||||||
|
#include "imageio.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <SDL_image.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -63,7 +64,7 @@ bool SFontPlus::utf8Code(unsigned char c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SFontPlus::initFont(const string &font, const string &characters) {
|
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) {
|
if (buf!=NULL) {
|
||||||
initFont( SDL_DisplayFormatAlpha(buf), characters );
|
initFont( SDL_DisplayFormatAlpha(buf), characters );
|
||||||
SDL_FreeSurface(buf);
|
SDL_FreeSurface(buf);
|
||||||
|
@ -18,15 +18,16 @@
|
|||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "surface.h"
|
||||||
|
#include "imageio.h"
|
||||||
|
#include "utilities.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include <SDL_gfxPrimitives.h>
|
#include <SDL_gfxPrimitives.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "surface.h"
|
|
||||||
#include "utilities.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
RGBAColor strtorgba(const string &strColor) {
|
RGBAColor strtorgba(const string &strColor) {
|
||||||
RGBAColor c = {0,0,0,255};
|
RGBAColor c = {0,0,0,255};
|
||||||
c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 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;
|
skinpath = img;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *buf = IMG_Load(skinpath.c_str());
|
SDL_Surface *buf = loadPNG(skinpath);
|
||||||
if (buf!=NULL) {
|
if (buf!=NULL) {
|
||||||
if (alpha)
|
if (alpha)
|
||||||
raw = SDL_DisplayFormatAlpha(buf);
|
raw = SDL_DisplayFormatAlpha(buf);
|
||||||
|
@ -20,9 +20,8 @@
|
|||||||
#ifndef SURFACE_H
|
#ifndef SURFACE_H
|
||||||
#define SURFACE_H
|
#define SURFACE_H
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_image.h>
|
#include <string>
|
||||||
|
|
||||||
#include "asfont.h"
|
#include "asfont.h"
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user