00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef CImageLoaderH
00024 #define CImageLoaderH
00025
00026 #include "graphics/CColor.h"
00027
00028
00029
00037
00038
00039
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041
00042
00047 char* find_extension(const char* a_input, const bool include_dot=0);
00048
00050 void find_filename(char* a_dest, const char* a_input, const bool a_includeExtension=false);
00051
00053 void replace_extension(char* a_dest, const char* a_input, const char* a_extension);
00054
00059 bool find_directory(char* a_dest, const char* a_source);
00060
00062 void string_tolower(char* a_dest, const char* a_source);
00063
00065 void chop_newlines(char* a_str);
00066
00068 unsigned char* readFile(const char* a_filename, bool a_readAsText);
00069
00070
00071 #endif // DOXYGEN_SHOULD_SKIP_THIS
00072
00073
00074
00084
00085 class cImageLoader
00086 {
00087 public:
00088
00089
00090
00091
00092
00094 cImageLoader();
00095
00097 cImageLoader(const char* filename);
00098
00100 virtual ~cImageLoader();
00101
00102
00103
00104
00105
00106
00108 inline unsigned char* getData() { return m_data; }
00109
00111 inline unsigned int getWidth() { return m_width; }
00112
00114 inline unsigned int getHeight() { return m_height; }
00115
00117 inline unsigned int getFormat() { return m_format; }
00118
00120 inline unsigned int getBitsPerPixel() { return m_bits_per_pixel; }
00121
00123 cColorb getPixelColor(const unsigned int a_x, const unsigned int a_y);
00124
00126 void setPixelColor(const unsigned int a_x, const unsigned int a_y, const cColorb& a_color);
00127
00129 void clear(const cColorb& a_color);
00130
00132 void replace(const cColorb& a_oldColor, const cColorb& a_newColor);
00133
00135 void allocate(const unsigned int a_width, const unsigned int a_height);
00136
00138 inline unsigned int initialized() { return m_initialized; }
00139
00141 bool loadFromFile(const char* filename);
00142
00144 bool loadFromFileOLE(const char* szPathName);
00145
00147 const char* getFilename() const { return (const char*)(m_filename); }
00148
00149
00150 protected:
00151
00152
00153
00154
00155
00157 void defaults();
00158
00160 void cleanup();
00161
00163 void convertToRGBA();
00164
00165
00166
00167
00168
00169
00171 char m_filename[CHAI_SIZE_PATH];
00172
00174 int m_width;
00175
00177 int m_height;
00178
00180 unsigned int m_format;
00181
00183 unsigned int m_bits_per_pixel;
00184
00186 unsigned char* m_data;
00187
00189 bool m_initialized;
00190 };
00191
00192
00193 #endif
00194