s/RageSurface/RageSurfaceUtils/

This commit is contained in:
Glenn Maynard
2004-06-13 20:19:28 +00:00
parent bc9bbb392c
commit f2578fe6a9
12 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ void RageBitmapTexture::Create()
/* Create (and return) a surface ready to be loaded to OpenGL */
/* Load the image into an SDL surface. */
SDL_Surface *img = RageSurface::LoadFile( actualID.filename );
SDL_Surface *img = RageSurfaceUtils::LoadFile( actualID.filename );
/* Tolerate corrupt/unknown images. */
if( img == NULL )
+10 -10
View File
@@ -9,13 +9,13 @@
#include "SDL_utils.h"
#include <set>
static RageSurface::OpenResult RageSurface_Load_BMP( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
static RageSurfaceUtils::OpenResult RageSurface_Load_BMP( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
{
RageFile f;
if( !f.Open(sPath) )
{
error = f.GetError();
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
SDL_RWops rw;
@@ -26,18 +26,18 @@ static RageSurface::OpenResult RageSurface_Load_BMP( const CString &sPath, SDL_S
if( ret == NULL )
{
error = SDL_GetError();
return RageSurface::OPEN_UNKNOWN_FILE_FORMAT;
return RageSurfaceUtils::OPEN_UNKNOWN_FILE_FORMAT;
}
mySDL_FixupPalettedAlpha( ret );
return RageSurface::OPEN_OK;
return RageSurfaceUtils::OPEN_OK;
}
static SDL_Surface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error, CString format, bool &bKeepTrying )
{
SDL_Surface *ret = NULL;
RageSurface::OpenResult result;
RageSurfaceUtils::OpenResult result;
if( !format.CompareNoCase("png") )
result = RageSurface_Load_PNG( sPath, ret, bHeaderOnly, error );
else if( !format.CompareNoCase("gif") )
@@ -53,7 +53,7 @@ static SDL_Surface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error
return NULL;
}
if( result == RageSurface::OPEN_OK )
if( result == RageSurfaceUtils::OPEN_OK )
{
ASSERT( ret );
return ret;
@@ -78,15 +78,15 @@ static SDL_Surface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error
* error", "permission denied"), in which case all other readers will probably fail,
* too. The returned error is used, and no other formats will be tried.
*/
bKeepTrying = (result != RageSurface::OPEN_FATAL_ERROR);
bKeepTrying = (result != RageSurfaceUtils::OPEN_FATAL_ERROR);
switch( result )
{
case RageSurface::OPEN_UNKNOWN_FILE_FORMAT:
case RageSurfaceUtils::OPEN_UNKNOWN_FILE_FORMAT:
bKeepTrying = true;
error = "Unknown file format";
break;
case RageSurface::OPEN_FATAL_ERROR:
case RageSurfaceUtils::OPEN_FATAL_ERROR:
/* The file matched, but failed to load. We know it's this type of data;
* don't bother trying the other file types. */
bKeepTrying = false;
@@ -96,7 +96,7 @@ static SDL_Surface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error
return NULL;
}
SDL_Surface *RageSurface::LoadFile( const CString &sPath, bool bHeaderOnly )
SDL_Surface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly )
{
{
RageFile TestOpen;
+1 -1
View File
@@ -2,7 +2,7 @@
#define RAGE_SURFACE_LOAD_H
struct SDL_Surface;
namespace RageSurface
namespace RageSurfaceUtils
{
enum OpenResult
{
+14 -14
View File
@@ -58,7 +58,7 @@ static int GetDataBlock( RageFile &f, unsigned char *buf )
}
RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
{
unsigned char buf[256];
int imageCount = 0;
@@ -68,18 +68,18 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( !f.Open( sPath ) )
{
error = f.GetError();
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
if( !ReadOK(f, buf, 6) )
{
error = "error reading magic number";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
if( strncmp((char *) buf, "GIF", 3) != 0 )
{
error = "not a GIF file";
return RageSurface::OPEN_UNKNOWN_FILE_FORMAT;
return RageSurfaceUtils::OPEN_UNKNOWN_FILE_FORMAT;
}
{
@@ -90,14 +90,14 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( (strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0) )
{
error = "bad version number, not '87a' or '89a'";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
}
if( !ReadOK(f, buf, 7) )
{
error = "failed to read screen descriptor";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
SDL_Color GlobalColorMap[MAXCOLORMAPSIZE];
@@ -111,7 +111,7 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( !ReadPalette(f, GlobalBitPixel, GlobalColorMap ) )
{
error = "error reading global colormap";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
}
@@ -123,7 +123,7 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( !ReadOK(f, &type, 1) )
{
error = "EOF / read error on image data";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
switch( type )
{
@@ -134,7 +134,7 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
{
error = ssprintf( "only %d image%s found in file",
imageCount, imageCount > 1 ? "s" : "");
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
}
@@ -145,7 +145,7 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( !ReadOK(f, &label, 1) )
{
error = "EOF / read error on extention function code";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
switch( label )
@@ -168,7 +168,7 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( !ReadOK(f, buf, 9) )
{
error = "couldn't read left/top/width/height";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
int bitPixel = 1 << ((buf[8] & 0x07) + 1);
@@ -179,7 +179,7 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( !ReadPalette(f, bitPixel, LocalColorMap) )
{
error = "error reading local colormap";
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
} else {
bitPixel = GlobalBitPixel;
@@ -196,13 +196,13 @@ RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface
if( transparency != -1 )
mySDL_AddColorKey( ret, transparency );
return RageSurface::OPEN_OK;
return RageSurfaceUtils::OPEN_OK;
}
default: continue; /* Not a valid start character */
}
}
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
struct LWZState
+1 -1
View File
@@ -2,7 +2,7 @@
#define RAGE_SURFACE_LOAD_GIF_H
#include "RageSurface_Load.h"
RageSurface::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
#endif
+4 -4
View File
@@ -195,13 +195,13 @@ static SDL_Surface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char err
}
RageSurface::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
RageSurfaceUtils::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
{
RageFile f;
if( !f.Open( sPath ) )
{
error = f.GetError();
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
char errorbuf[1024];
@@ -209,10 +209,10 @@ RageSurface::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface
if( ret == NULL )
{
error = errorbuf;
return RageSurface::OPEN_UNKNOWN_FILE_FORMAT; // XXX
return RageSurfaceUtils::OPEN_UNKNOWN_FILE_FORMAT; // XXX
}
return RageSurface::OPEN_OK;
return RageSurfaceUtils::OPEN_OK;
}
/*
+1 -1
View File
@@ -2,7 +2,7 @@
#define RAGE_SURFACE_LOAD_JPEG_H
#include "RageSurface_Load.h"
RageSurface::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
RageSurfaceUtils::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
#endif
+4 -4
View File
@@ -236,13 +236,13 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
}
RageSurface::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
RageSurfaceUtils::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
{
RageFile f;
if( !f.Open( sPath ) )
{
error = f.GetError();
return RageSurface::OPEN_FATAL_ERROR;
return RageSurfaceUtils::OPEN_FATAL_ERROR;
}
char errorbuf[1024];
@@ -250,10 +250,10 @@ RageSurface::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface
if( ret == NULL )
{
error = errorbuf;
return RageSurface::OPEN_UNKNOWN_FILE_FORMAT; // XXX
return RageSurfaceUtils::OPEN_UNKNOWN_FILE_FORMAT; // XXX
}
return RageSurface::OPEN_OK;
return RageSurfaceUtils::OPEN_OK;
}
/*
+1 -1
View File
@@ -2,7 +2,7 @@
#define RAGE_SURFACE_LOAD_PNG_H
#include "RageSurface_Load.h"
RageSurface::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
RageSurfaceUtils::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
#endif
+1 -1
View File
@@ -497,7 +497,7 @@ void mySDL_WM_SetIcon( CString sIconFile )
return;
}
SDL_Surface *srf = RageSurface::LoadFile(sIconFile);
SDL_Surface *srf = RageSurfaceUtils::LoadFile(sIconFile);
if( srf == NULL )
return;
+1 -1
View File
@@ -697,7 +697,7 @@ void Song::TidyUpData()
CString sPath = m_sSongDir + arrayImages[i];
/* We only care about the dimensions. */
SDL_Surface *img = RageSurface::LoadFile( sPath, true );
SDL_Surface *img = RageSurfaceUtils::LoadFile( sPath, true );
if( !img )
{
LOG->Trace("Couldn't load '%s': %s", sPath.c_str(), SDL_GetError());
@@ -13,7 +13,7 @@ static HBITMAP g_hBitmap = NULL;
/* Load a file into a GDI surface. */
HBITMAP LoadWin32Surface( CString fn )
{
SDL_Surface *s = RageSurface::LoadFile( fn );
SDL_Surface *s = RageSurfaceUtils::LoadFile( fn );
if( s == NULL )
return NULL;