/** * @module CPixMap * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) * @brief Implementation of CFile CBitmap handling XPM. * @date 27.04.2009 */ #ifndef CPixMap_H #define CPixMap_H #include #include #include "cbitmap.h" /** * @class CBitmap * @brief Implementation of CFile handling Windows Bitmaps. * * In order to support operations on bitmaps with different color bitcounts * different implementations of CPixelFormat are used. These classes are * allowed to modify the bitmap headers and pixelbuffer directly. * * On error CFile::FileError is thrown. */ class CPixMap : public CBitmap { public: /** * @method CPixMap * @brief Default ctor * @param - * @return - * @globalvars none * @exception none * @conditions none */ CPixMap(); /** * @method ~CPixMap * @brief Default dtor * @param - * @return - * @globalvars none * @exception none * @conditions none */ ~CPixMap() {} /** * @method read * @brief Reads Windows Bitmap from filestream. * On error an exception is thrown. * @param in filestream to read data from * @return - * @globalvars none * @exception CFile::FileError * @exception bad_alloc * @conditions none */ void read(std::ifstream& in); /** * @method write * @brief Writes Windows Bitmap to filestream. * @param out filestream to read data from * @return - * @globalvars none * @exception FileError * @exception bad_alloc * @conditions none */ void write(std::ofstream& out); #ifdef DEBUG /** * @method dump * @brief Dumps the Windows Bitmap file headers to ostream * @param out output stream * @return - * @globalvars * @exception * @conditions */ void dump(std::ostream& out); #endif /** * @brief Windows Bitmap Info Header structure */ #pragma pack(push,1) typedef struct { /** the xpm width in pixels (signed integer) */ uint32_t xpmWidth; /** the xpm height in pixels (signed integer) */ uint32_t xpmHeight; /** the number of colors (signed integer) */ uint32_t nColor; /** the number of characters per pixel (signed integer) */ uint32_t nChar; /** X-Position Hotspots */ uint32_t xHotspot; /** Y-Position Hotspots */ uint32_t yHotspot; /* color tables*/ // std::map > xpmColors; // std::map xpmColors; } PIXMAP_FILEHEADER; #pragma pack(pop) /* TODO */ const uint32_t getPixelDataSize() { return m_fileheader.xpmWidth * m_fileheader.xpmHeight * m_fileheader.nChar; } /* TODO */ const uint32_t getHeight() { /* width and height can be negativ */ return m_fileheader.xpmHeight; } /* TODO */ const uint32_t getWidth() { /* width and height can be negativ */ return m_fileheader.xpmWidth; } /* TODO */ const bool isMirrored() { /* pixmap is never mirrored */ return false; } protected: /* members */ /** fileheader */ PIXMAP_FILEHEADER m_fileheader; /** infoheader */ }; #endif /* vim: set et sw=2 ts=2: */