From b40bfe580d2dc9038c00521a44fcd6edd352f239 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 26 Mar 2005 01:54:25 +0000 Subject: Images are now exclusively loaded through PhysFS, and Tiled maps should load fine again. --- src/resources/image.cpp | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'src/resources/image.cpp') diff --git a/src/resources/image.cpp b/src/resources/image.cpp index a8af4e13..5114d1d3 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -50,18 +50,16 @@ Image::~Image() unload(); } -Image* Image::load(const std::string &filePath, int flags) +Image* Image::load(void* buffer, unsigned int bufferSize, int flags) { - logger.log("Image::load(%s)", filePath.c_str()); + // Load the raw file data from the buffer in an RWops structure + SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); - // Attempt to use SDL_Image to load the file. - SDL_Surface *tmpImage = IMG_Load(filePath.c_str()); + // Use SDL_Image to load the raw image data + SDL_Surface* tmpImage = IMG_Load_RW(rw, 1); - // Check if the file was opened and return the appropriate value. - if (!tmpImage) { - logger.log("Error: Image load failed."); - return NULL; - } + // Now free the SDL_RWops data + //SDL_FreeRW(rw); #ifndef USE_OPENGL @@ -196,26 +194,6 @@ Image* Image::load(const std::string &filePath, int flags) } return new Image(texture, width, height, realWidth, realHeight); - -#endif -} - -Image* Image::load(void* buffer, unsigned int bufferSize) -{ - // Load the raw file data from the buffer in an RWops structure - SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize); - - // Use SDL_Image to load the raw image data - SDL_Surface* texture = IMG_Load_RW(rw, 1); - - // Now free the SDL_RWops data - //SDL_FreeRW(rw); - -#ifndef USE_OPENGL - return new Image(texture); -#else - return new Image(0, 0, 0, 0, 0); - // Warning: need implementation to use with OpenGL #endif } -- cgit v1.2.3-70-g09d2