summaryrefslogtreecommitdiff
path: root/src/resources/image.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-20 12:27:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-20 12:27:56 +0000
commitca58ec1faedca0081ecd233f2cefa1ba783cebf4 (patch)
tree11216c01bb8867a9bd4ad6d4b8bdefc3c61a952a /src/resources/image.cpp
parent5a7abdafdac8f6ddd7972cadbc7e20563a0a29fc (diff)
downloadmana-client-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.tar.gz
mana-client-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.tar.bz2
mana-client-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.tar.xz
mana-client-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.zip
Merged revisions 3642,3662-3664,3667 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk ........ r3642 | gmelquio | 2007-10-19 19:46:46 +0200 (Fri, 19 Oct 2007) | 1 line Factored code between resource handlers. Implemented failure-friendly sprite loader. ........ r3662 | gmelquio | 2007-10-21 21:01:16 +0200 (Sun, 21 Oct 2007) | 1 line Added persistent positioning. ........ r3663 | gmelquio | 2007-10-21 21:03:43 +0200 (Sun, 21 Oct 2007) | 1 line Fixed missing pixels at bottom and right. ........ r3664 | gmelquio | 2007-10-21 21:05:56 +0200 (Sun, 21 Oct 2007) | 1 line Changed to use default values when restoring missing settings. ........ r3667 | gmelquio | 2007-10-21 22:09:08 +0200 (Sun, 21 Oct 2007) | 1 line Fixed invisible text in dropboxes and shopboxes. ........
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r--src/resources/image.cpp35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 995e34b0..7a394edb 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -33,8 +33,7 @@ int Image::mTextureType = 0;
int Image::mTextureSize = 0;
#endif
-Image::Image(const std::string &idPath, SDL_Surface *image):
- Resource(idPath),
+Image::Image(SDL_Surface *image):
#ifdef USE_OPENGL
mGLImage(0),
#endif
@@ -48,9 +47,8 @@ Image::Image(const std::string &idPath, SDL_Surface *image):
}
#ifdef USE_OPENGL
-Image::Image(const std::string &idPath, GLuint glimage, int width, int height,
+Image::Image(GLuint glimage, int width, int height,
int texWidth, int texHeight):
- Resource(idPath),
mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight),
@@ -69,36 +67,25 @@ Image::~Image()
unload();
}
-Image* Image::load(void *buffer, unsigned int bufferSize,
- const std::string &idPath)
+Resource *Image::load(void *buffer, unsigned bufferSize)
{
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
- SDL_Surface *tmpImage;
+ SDL_Surface *tmpImage = IMG_Load_RW(rw, 1);
- // Use SDL_Image to load the raw image data and have it free the data
- if (!idPath.compare(idPath.length() - 4, 4, ".tga"))
+ if (!tmpImage)
{
- tmpImage = IMG_LoadTyped_RW(rw, 1, const_cast<char*>("TGA"));
- }
- else
- {
- tmpImage = IMG_Load_RW(rw, 1);
- }
-
- if (!tmpImage) {
logger->log("Error, image load failed: %s", IMG_GetError());
return NULL;
}
- Image *image = load(tmpImage, idPath);
+ Image *image = load(tmpImage);
SDL_FreeSurface(tmpImage);
-
return image;
}
-Image *Image::load(SDL_Surface *tmpImage, std::string const &idPath)
+Image *Image::load(SDL_Surface *tmpImage)
{
#ifdef USE_OPENGL
if (mUseOpenGL)
@@ -198,7 +185,7 @@ Image *Image::load(SDL_Surface *tmpImage, std::string const &idPath)
return NULL;
}
- return new Image(idPath, texture, width, height, realWidth, realHeight);
+ return new Image(texture, width, height, realWidth, realHeight);
}
#endif
@@ -238,7 +225,7 @@ Image *Image::load(SDL_Surface *tmpImage, std::string const &idPath)
return NULL;
}
- return new Image(idPath, image);
+ return new Image(image);
}
void Image::unload()
@@ -324,7 +311,7 @@ Image::powerOfTwo(int input)
SubImage::SubImage(Image *parent, SDL_Surface *image,
int x, int y, int width, int height):
- Image("", image), mParent(parent)
+ Image(image), mParent(parent)
{
mParent->incRef();
@@ -339,7 +326,7 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
SubImage::SubImage(Image *parent, GLuint image,
int x, int y, int width, int height,
int texWidth, int texHeight):
- Image("", image, width, height, texWidth, texHeight), mParent(parent)
+ Image(image, width, height, texWidth, texHeight), mParent(parent)
{
mParent->incRef();