#include <CSBitmap.h>
Inheritance diagram for CSBitmapLoader:
The Class provides:
This class (or the loader... that is) holds the images as they are loaded, Upon switching between different resolutions, the surfaces are "recreated" using the images that are hold within the loader class. Thus the used images are allways recreated from the original bitmap. Also this one holds the transparent-rgb values for (re-)setting the color-key values.
The Loader IS responsible for freeing the surface.(parent class!) (thru destroy)
Definition at line 49 of file CSBitmap.h.
Static Public Member Functions | |
void | scale (char *name, int width, int divideX, int height, int divideY) |
Static Public Attributes | |
CSBitmapLoader | INSTANCE |
Protected Member Functions | |
virtual void | destroy (CSBitmap *image) |
virtual CSBitmap * | create (const std::string &filename) |
|
Reimplemented from Loadable< CSBitmap >. Definition at line 63 of file CSBitmap.cpp. References SDLMain::freeSurface(), and CSBitmap::picture.
00064 { 00065 SDLMain::freeSurface(image->picture); 00066 delete image; 00067 } |
Here is the call graph for this function:
|
Implements Loadable< CSBitmap >. Reimplemented in CSBitmapDirectLoader. Definition at line 13 of file CSBitmap.cpp. References CSBitmap::b, CSBitmap::g, CSXMLHelper::getError(), CSXMLHelper::getErrorMessage(), CSXMLHelper::getInt(), CSXMLHelper::getString(), LOG_EXIT, CSBitmap::picture, CSBitmap::r, and SDLMain::shutdown().
00014 { 00015 CSXMLHelper xmlSupport(filename, "BITMAP"); 00016 char *id; 00017 char *bitmapFilename; 00018 signed int r,g,b; 00019 try 00020 { 00021 if (xmlSupport.getError()) 00022 { 00023 throw "error"; 00024 } 00025 00026 id = strdup(xmlSupport.getString("ID").c_str()); 00027 bitmapFilename = strdup(xmlSupport.getString("NAME").c_str()); 00028 r = xmlSupport.getInt("TRANSPARENT_COLOR/RED"); 00029 g = xmlSupport.getInt("TRANSPARENT_COLOR/GREEN"); 00030 b = xmlSupport.getInt("TRANSPARENT_COLOR/BLUE"); 00031 } 00032 catch(...) 00033 { 00034 LOG_EXIT 00035 SDLMain::shutdown((std::string)"XML error \"" + filename + "\": " + xmlSupport.getErrorMessage().c_str(), 1); 00036 } 00037 00038 SDL_Surface *image = 0; 00039 00040 /* Load the BMP file into a surface */ 00041 image = SDL_LoadBMP(bitmapFilename); 00042 00043 if (image == 0) 00044 { 00045 LOG_EXIT 00046 SDLMain::shutdown((std::string)"Couldn't load \"" + bitmapFilename + "\": " + SDL_GetError(), 1); 00047 } 00048 00049 // free loaded parse entities! 00050 free (bitmapFilename); 00051 bitmapFilename = 0; 00052 free (id); 00053 id = 0; 00054 00055 CSBitmap *bitmap = new CSBitmap(); 00056 bitmap->r = r; 00057 bitmap->g = g; 00058 bitmap->b = b; 00059 bitmap->picture = image; 00060 return bitmap; 00061 } |
Here is the call graph for this function:
|
Definition at line 72 of file CSBitmap.cpp. References BitmapMap, SDLMain::freeSurface(), SDLMain::getInstance(), Loadable< CSBitmap >::getMap(), INSTANCE, CSBitmap::picture, and SDLMain::scale(). Referenced by CSPicture::scale().
00073 { 00074 BitmapMap *map = CSBitmapLoader::INSTANCE.getMap(); 00075 BitmapMap::iterator iter = map->find(name); 00076 if (iter == map->end()) 00077 { 00078 return; 00079 } 00080 CSBitmap *bitmap = iter->second; 00081 SDL_Surface *surface = bitmap->picture; 00082 bitmap->picture = SDLMain::getInstance()->scale(surface, width, divideX, height, divideY); 00083 SDLMain::freeSurface(surface); 00084 } |
Here is the call graph for this function:
|
Reimplemented in CSBitmapDirectLoader. Definition at line 10 of file CSBitmap.cpp. Referenced by scale(). |