00001 00008 #ifndef CPixmap_H 00009 #define CPixmap_H 00010 00011 #include <stdint.h> 00012 #include "cbitmap.h" 00013 00014 #define PIXMAP_IDENTIFIER "/* XPM */" 00015 #define PIXMAP_COLORCHARS ".#abcdefghijklmnopqrstuvwxyzABCD" \ 00016 "EFGHIJKLMNOPQRSTUVWXYZ0123456789" 00017 00028 class CPixmap : public CBitmap 00029 { 00030 public: 00040 CPixmap(); 00041 00051 ~CPixmap() 00052 {} 00053 00065 void read(std::ifstream& in); 00066 00077 void write(std::ofstream& out); 00078 00079 #ifdef DEBUG 00080 00089 void dump(std::ostream& out); 00090 #endif 00091 00101 const uint32_t getPixelDataSize() 00102 { 00103 return m_fileheader.width * m_fileheader.height * sizeof(uint32_t); 00104 } 00105 00115 const uint32_t getHeight() 00116 { 00117 return m_fileheader.height; 00118 } 00119 00129 const uint32_t getWidth() 00130 { 00131 return m_fileheader.width; 00132 } 00133 00144 const bool hasColorTable() 00145 { 00146 return true; 00147 } 00148 00158 const bool isMirrored() 00159 { 00160 /* pixmap is never mirrored */ 00161 return false; 00162 } 00163 00164 protected: 00175 std::string getLine(std::ifstream& in, bool ignore_comments = true); 00176 00186 std::string getCArrayLine(std::ifstream& in); 00187 00198 const std::string getXPMColorID(unsigned int index, unsigned int length); 00199 00203 typedef struct 00204 { 00206 uint32_t width; 00208 uint32_t height; 00210 uint32_t nColor; 00212 uint32_t nChar; 00214 uint32_t xHotspot; 00216 uint32_t yHotspot; 00218 bool _HOTSPOT; 00220 bool _XPMEXT; 00222 std::string extension; 00223 } PIXMAP_FILEHEADER; 00224 00225 /* members */ 00227 PIXMAP_FILEHEADER m_fileheader; 00229 std::string m_imagename; 00230 }; 00231 00232 #endif 00233 00234 /* vim: set et sw=2 ts=2: */
1.5.3