/** * @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 "cbitmap.h" /** * @class CPixmap * @brief Implementation of CFile handling Pixmap file format. * * In order to support operations on pixmaps in color mode an * implementations of CPixelFormat is used. These classe are * allowed to modify the pixmap header, pixelbuffer and color table 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 Pixmap 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 Pixmap to filestream. * @param out filestream to read data from * @return - * @globalvars none * @exception FileError * @exception bad_alloc * @conditions none */ void write(std::ofstream& out, std::string& filename); #ifdef DEBUG /** * @method dump * @brief Dumps the Pixmap file header and pixel data to ostream * @param out output stream * @return - * @globalvars * @exception * @conditions */ void dump(std::ostream& out); #endif /** * @brief Pixmap 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; /* is hotspot set */ bool _HOTSPOT; /* XPMEXT extension tag found*/ bool _XPMEXT; /* unchanged extension */ std::string extension; } 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; } /** * @method hasColorTable * @brief Check if bitmap has a colortable * (we don't support this yet for windows bitmaps) * @param - * @return true if bitmap has a colortable. false otherwise * @globalvars none * @exception none * @conditions none */ const bool hasColorTable() { return true; } /* 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: */