diff options
| author | manuel <manuel@nc8430.lan> | 2009-05-01 15:41:07 +0200 |
|---|---|---|
| committer | manuel <manuel@nc8430.lan> | 2009-05-01 15:41:07 +0200 |
| commit | 766a0da4ab39c26e1d3b591f46cdadcfbe0f8a73 (patch) | |
| tree | f383a621f2ad762e5be250c2ba9bd4c18bb02a0c /ue2/imgsynth2/cpixmap.h | |
| parent | f0442c8d058ae6007023ba1b898197db921e6ce1 (diff) | |
| parent | b0442de485dcb6328366d9b05a62af345e5fa39f (diff) | |
| download | ooprog-766a0da4ab39c26e1d3b591f46cdadcfbe0f8a73.tar.gz ooprog-766a0da4ab39c26e1d3b591f46cdadcfbe0f8a73.tar.bz2 ooprog-766a0da4ab39c26e1d3b591f46cdadcfbe0f8a73.zip | |
merge
Diffstat (limited to 'ue2/imgsynth2/cpixmap.h')
| -rw-r--r-- | ue2/imgsynth2/cpixmap.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h new file mode 100644 index 0000000..eb219aa --- /dev/null +++ b/ue2/imgsynth2/cpixmap.h | |||
| @@ -0,0 +1,166 @@ | |||
| 1 | /** | ||
| 2 | * @module CPixmap | ||
| 3 | * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) | ||
| 4 | * @brief Implementation of CFile CBitmap handling XPM. | ||
| 5 | * @date 27.04.2009 | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef CPixmap_H | ||
| 9 | #define CPixmap_H | ||
| 10 | |||
| 11 | #include <stdint.h> | ||
| 12 | #include "cbitmap.h" | ||
| 13 | |||
| 14 | /** | ||
| 15 | * @class CPixmap | ||
| 16 | * @brief Implementation of CFile handling Pixmap file format. | ||
| 17 | * | ||
| 18 | * In order to support operations on pixmaps in color mode an | ||
| 19 | * implementations of CPixelFormat is used. These classe are | ||
| 20 | * allowed to modify the pixmap header, pixelbuffer and color table directly. | ||
| 21 | * | ||
| 22 | * On error CFile::FileError is thrown. | ||
| 23 | */ | ||
| 24 | class CPixmap : public CBitmap | ||
| 25 | { | ||
| 26 | public: | ||
| 27 | /** | ||
| 28 | * @method CPixmap | ||
| 29 | * @brief Default ctor | ||
| 30 | * @param - | ||
| 31 | * @return - | ||
| 32 | * @globalvars none | ||
| 33 | * @exception none | ||
| 34 | * @conditions none | ||
| 35 | */ | ||
| 36 | CPixmap(); | ||
| 37 | |||
| 38 | /** | ||
| 39 | * @method ~CPixmap | ||
| 40 | * @brief Default dtor | ||
| 41 | * @param - | ||
| 42 | * @return - | ||
| 43 | * @globalvars none | ||
| 44 | * @exception none | ||
| 45 | * @conditions none | ||
| 46 | */ | ||
| 47 | ~CPixmap() | ||
| 48 | {} | ||
| 49 | |||
| 50 | /** | ||
| 51 | * @method read | ||
| 52 | * @brief Reads Pixmap from filestream. | ||
| 53 | * On error an exception is thrown. | ||
| 54 | * @param in filestream to read data from | ||
| 55 | * @return - | ||
| 56 | * @globalvars none | ||
| 57 | * @exception CFile::FileError | ||
| 58 | * @exception bad_alloc | ||
| 59 | * @conditions none | ||
| 60 | */ | ||
| 61 | void read(std::ifstream& in); | ||
| 62 | |||
| 63 | /** | ||
| 64 | * @method write | ||
| 65 | * @brief Writes Pixmap to filestream. | ||
| 66 | * @param out filestream to read data from | ||
| 67 | * @return - | ||
| 68 | * @globalvars none | ||
| 69 | * @exception FileError | ||
| 70 | * @exception bad_alloc | ||
| 71 | * @conditions none | ||
| 72 | */ | ||
| 73 | void write(std::ofstream& out, std::string& filename); | ||
| 74 | |||
| 75 | #ifdef DEBUG | ||
| 76 | /** | ||
| 77 | * @method dump | ||
| 78 | * @brief Dumps the Pixmap file header and pixel data to ostream | ||
| 79 | * @param out output stream | ||
| 80 | * @return - | ||
| 81 | * @globalvars | ||
| 82 | * @exception | ||
| 83 | * @conditions | ||
| 84 | */ | ||
| 85 | void dump(std::ostream& out); | ||
| 86 | #endif | ||
| 87 | |||
| 88 | /** | ||
| 89 | * @brief Pixmap Header structure | ||
| 90 | */ | ||
| 91 | #pragma pack(push,1) | ||
| 92 | typedef struct | ||
| 93 | { | ||
| 94 | /** the xpm width in pixels (signed integer) */ | ||
| 95 | uint32_t xpmWidth; | ||
| 96 | /** the xpm height in pixels (signed integer) */ | ||
| 97 | uint32_t xpmHeight; | ||
| 98 | /** the number of colors (signed integer) */ | ||
| 99 | uint32_t nColor; | ||
| 100 | /** the number of characters per pixel (signed integer) */ | ||
| 101 | uint32_t nChar; | ||
| 102 | /** X-Position Hotspots */ | ||
| 103 | uint32_t xHotspot; | ||
| 104 | /** Y-Position Hotspots */ | ||
| 105 | uint32_t yHotspot; | ||
| 106 | /* is hotspot set */ | ||
| 107 | bool _HOTSPOT; | ||
| 108 | /* XPMEXT extension tag found*/ | ||
| 109 | bool _XPMEXT; | ||
| 110 | /* unchanged extension */ | ||
| 111 | std::string extension; | ||
| 112 | } PIXMAP_FILEHEADER; | ||
| 113 | #pragma pack(pop) | ||
| 114 | |||
| 115 | /* TODO */ | ||
| 116 | const uint32_t getPixelDataSize() | ||
| 117 | { | ||
| 118 | return m_fileheader.xpmWidth * m_fileheader.xpmHeight * m_fileheader.nChar; | ||
| 119 | } | ||
| 120 | |||
| 121 | /* TODO */ | ||
| 122 | const uint32_t getHeight() | ||
| 123 | { | ||
| 124 | /* width and height can be negativ */ | ||
| 125 | return m_fileheader.xpmHeight; | ||
| 126 | } | ||
| 127 | |||
| 128 | /* TODO */ | ||
| 129 | const uint32_t getWidth() | ||
| 130 | { | ||
| 131 | /* width and height can be negativ */ | ||
| 132 | return m_fileheader.xpmWidth; | ||
| 133 | } | ||
| 134 | |||
| 135 | /** | ||
| 136 | * @method hasColorTable | ||
| 137 | * @brief Check if bitmap has a colortable | ||
| 138 | * (we don't support this yet for windows bitmaps) | ||
| 139 | * @param - | ||
| 140 | * @return true if bitmap has a colortable. false otherwise | ||
| 141 | * @globalvars none | ||
| 142 | * @exception none | ||
| 143 | * @conditions none | ||
| 144 | */ | ||
| 145 | const bool hasColorTable() | ||
| 146 | { | ||
| 147 | return true; | ||
| 148 | } | ||
| 149 | |||
| 150 | /* TODO */ | ||
| 151 | const bool isMirrored() | ||
| 152 | { | ||
| 153 | /* pixmap is never mirrored */ | ||
| 154 | return false; | ||
| 155 | } | ||
| 156 | |||
| 157 | protected: | ||
| 158 | /* members */ | ||
| 159 | /** fileheader */ | ||
| 160 | PIXMAP_FILEHEADER m_fileheader; | ||
| 161 | /** infoheader */ | ||
| 162 | }; | ||
| 163 | |||
| 164 | #endif | ||
| 165 | |||
| 166 | /* vim: set et sw=2 ts=2: */ | ||
