From b9ce1555b2baf9be209775dbd4c8b217db5cd735 Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 1 May 2009 20:18:51 +0200 Subject: rewrote pixmap::read to do more sanity checks --- ue2/imgsynth2/cwindowsbitmap.h | 129 ++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 79 deletions(-) (limited to 'ue2/imgsynth2/cwindowsbitmap.h') diff --git a/ue2/imgsynth2/cwindowsbitmap.h b/ue2/imgsynth2/cwindowsbitmap.h index 9fb40db..28eb88d 100644 --- a/ue2/imgsynth2/cwindowsbitmap.h +++ b/ue2/imgsynth2/cwindowsbitmap.h @@ -60,14 +60,13 @@ class CWindowsBitmap : public CBitmap * @method write * @brief Writes Windows Bitmap to filestream. * @param out filestream to read data from - * @param filename filename (maybe useful for some handlers) * @return - * @globalvars none * @exception FileError * @exception bad_alloc * @conditions none */ - void write(std::ofstream& out, std::string& filename); + void write(std::ofstream& out); #ifdef DEBUG /** @@ -82,83 +81,6 @@ class CWindowsBitmap : public CBitmap void dump(std::ostream& out); #endif - /** - * @brief Windows Bitmap File Header structure - */ -#pragma pack(push,1) - typedef struct - { - /** the magic number used to identify the BMP file */ - uint8_t bfType[2]; - /** the size of the BMP file in bytes */ - uint32_t bfSize; - /** reserved */ - uint32_t bfReserved; - /** the offset of the byte where the bitmap data can be found */ - uint32_t bfOffBits; - } BITMAP_FILEHEADER; -#pragma pack(pop) - - /** - * @brief Windows Bitmap Info Header structure - */ -#pragma pack(push,1) - typedef struct - { - /** the size of this header (40 bytes) */ - uint32_t biSize; - /** the bitmap width in pixels (signed integer) */ - int32_t biWidth; - /** the bitmap height in pixels (signed integer) */ - int32_t biHeight; - /** the number of color planes being used. Must be set to 1 */ - uint16_t biPlanes; - /** the number of bits per pixel, which is the color depth of the image */ - uint16_t biBitCount; - /** the compression method being used */ - uint32_t biCompression; - /** the image size */ - uint32_t biSizeImage; - /** the horizontal resolution of the image (pixel per meter) */ - int32_t biXPelsPerMeter; - /** the vertical resolution of the image (pixel per meter) */ - int32_t biYPelsPerMeter; - /** the number of colors in the color palette, or 0 to default to 2^n */ - uint32_t biClrUsed; - /** the number of important colors used, or 0 when every color is - * important; generally ignored. */ - uint32_t biClrImportant; - } BITMAP_INFOHEADER; -#pragma pack(pop) - - /** - * @method getFileHeader - * @brief Returns reference to fileheader structure of bitmap - * @param - - * @return reference to fileheader structure - * @globalvars none - * @exception none - * @conditions none - */ - BITMAP_FILEHEADER &getFileHeader() - { - return m_fileheader; - } - - /** - * @method getInfoHeader - * @brief Returns reference to infoheader structure of bitmap - * @param - - * @return reference to infoheader structure - * @globalvars none - * @exception none - * @conditions none - */ - BITMAP_INFOHEADER &getInfoHeader() - { - return m_infoheader; - } - /** * @method getPixelDataSize * @brief Return size of pixelbuffer @@ -234,6 +156,55 @@ class CWindowsBitmap : public CBitmap } protected: + /** + * @brief Windows Bitmap File Header structure + */ +#pragma pack(push,1) + typedef struct + { + /** the magic number used to identify the BMP file */ + uint8_t bfType[2]; + /** the size of the BMP file in bytes */ + uint32_t bfSize; + /** reserved */ + uint32_t bfReserved; + /** the offset of the byte where the bitmap data can be found */ + uint32_t bfOffBits; + } BITMAP_FILEHEADER; +#pragma pack(pop) + + /** + * @brief Windows Bitmap Info Header structure + */ +#pragma pack(push,1) + typedef struct + { + /** the size of this header (40 bytes) */ + uint32_t biSize; + /** the bitmap width in pixels (signed integer) */ + int32_t biWidth; + /** the bitmap height in pixels (signed integer) */ + int32_t biHeight; + /** the number of color planes being used. Must be set to 1 */ + uint16_t biPlanes; + /** the number of bits per pixel, which is the color depth of the image */ + uint16_t biBitCount; + /** the compression method being used */ + uint32_t biCompression; + /** the image size */ + uint32_t biSizeImage; + /** the horizontal resolution of the image (pixel per meter) */ + int32_t biXPelsPerMeter; + /** the vertical resolution of the image (pixel per meter) */ + int32_t biYPelsPerMeter; + /** the number of colors in the color palette, or 0 to default to 2^n */ + uint32_t biClrUsed; + /** the number of important colors used, or 0 when every color is + * important; generally ignored. */ + uint32_t biClrImportant; + } BITMAP_INFOHEADER; +#pragma pack(pop) + /* members */ /** fileheader */ BITMAP_FILEHEADER m_fileheader; -- cgit v1.2.3