From f2872bfd97f9297b1446f1fd6595a32dc509f301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Neuwirth?= Date: Wed, 29 Apr 2009 04:10:10 +0200 Subject: Adding cpixmap.cpp, cpixmap.h and test fieles --- ue2/imgsynth2/cpixmap.h | 162 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 ue2/imgsynth2/cpixmap.h (limited to 'ue2/imgsynth2/cpixmap.h') diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h new file mode 100644 index 0000000..6e147ed --- /dev/null +++ b/ue2/imgsynth2/cpixmap.h @@ -0,0 +1,162 @@ +/** + * @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; + + + + } 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: */ -- cgit v1.2.3 From b03b7611a300d3004b445be45e07c40ae0d13032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Neuwirth?= Date: Wed, 29 Apr 2009 23:00:30 +0200 Subject: assimilation --- ue2/imgsynth2/cpixmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ue2/imgsynth2/cpixmap.h') diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h index 6e147ed..c7537cd 100644 --- a/ue2/imgsynth2/cpixmap.h +++ b/ue2/imgsynth2/cpixmap.h @@ -112,8 +112,8 @@ class CPixMap : public CBitmap uint32_t yHotspot; /* color tables*/ - std::map > xpmColors; - + // std::map > xpmColors; + // std::map xpmColors; } PIXMAP_FILEHEADER; -- cgit v1.2.3 From b0442de485dcb6328366d9b05a62af345e5fa39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Neuwirth?= Date: Fri, 1 May 2009 14:58:58 +0200 Subject: Adding cpixelformat_indexd8.h and .cpp. Adding virtual methode getColorMode to CPixelFormat. Adding color table to CBitmap. Adding implementation of CPixmap --- ue2/imgsynth2/cpixmap.h | 62 +++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'ue2/imgsynth2/cpixmap.h') diff --git a/ue2/imgsynth2/cpixmap.h b/ue2/imgsynth2/cpixmap.h index c7537cd..863cbd4 100644 --- a/ue2/imgsynth2/cpixmap.h +++ b/ue2/imgsynth2/cpixmap.h @@ -1,33 +1,32 @@ /** - * @module CPixMap + * @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 +#ifndef CPixmap_H +#define CPixmap_H #include -#include #include "cbitmap.h" /** - * @class CBitmap - * @brief Implementation of CFile handling Windows Bitmaps. + * @class CPixmap + * @brief Implementation of CFile handling Pixmap file format. * - * 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. + * 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 +class CPixmap : public CBitmap { public: /** - * @method CPixMap + * @method CPixmap * @brief Default ctor * @param - * @return - @@ -35,10 +34,10 @@ class CPixMap : public CBitmap * @exception none * @conditions none */ - CPixMap(); + CPixmap(); /** - * @method ~CPixMap + * @method ~CPixmap * @brief Default dtor * @param - * @return - @@ -46,12 +45,12 @@ class CPixMap : public CBitmap * @exception none * @conditions none */ - ~CPixMap() + ~CPixmap() {} /** * @method read - * @brief Reads Windows Bitmap from filestream. + * @brief Reads Pixmap from filestream. * On error an exception is thrown. * @param in filestream to read data from * @return - @@ -64,7 +63,7 @@ class CPixMap : public CBitmap /** * @method write - * @brief Writes Windows Bitmap to filestream. + * @brief Writes Pixmap to filestream. * @param out filestream to read data from * @return - * @globalvars none @@ -73,11 +72,11 @@ class CPixMap : public CBitmap * @conditions none */ - void write(std::ofstream& out); + void write(std::ofstream& out, std::string& filename); #ifdef DEBUG /** * @method dump - * @brief Dumps the Windows Bitmap file headers to ostream + * @brief Dumps the Pixmap file header and pixel data to ostream * @param out output stream * @return - * @globalvars @@ -90,7 +89,7 @@ class CPixMap : public CBitmap /** - * @brief Windows Bitmap Info Header structure + * @brief Pixmap Header structure */ #pragma pack(push,1) typedef struct @@ -101,25 +100,23 @@ class CPixMap : public CBitmap 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; + /* 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 * @@ -127,21 +124,20 @@ class CPixMap : public CBitmap 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 */ -- cgit v1.2.3