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/cpixelformat_indexed8.cpp | 90 +++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 ue2/imgsynth2/cpixelformat_indexed8.cpp (limited to 'ue2/imgsynth2/cpixelformat_indexed8.cpp') diff --git a/ue2/imgsynth2/cpixelformat_indexed8.cpp b/ue2/imgsynth2/cpixelformat_indexed8.cpp new file mode 100644 index 0000000..c62a1ba --- /dev/null +++ b/ue2/imgsynth2/cpixelformat_indexed8.cpp @@ -0,0 +1,90 @@ +/** + * @module CPixelFormat_Indexed8 + * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) + * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. + * @date 18.04.2009 + */ + +#include +#include "cpixelformat_indexed8.h" + +using namespace std; + +void CPixelFormat_Indexed8::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) +{ + /* + * pixel[0] ... red + * pixel[1] ... green + * pixel[2] ... blue + */ + // if (m_bitmap->getPixelData() == NULL) + // throw PixelFormatError("No pixelbuffer allocated."); + + /* calc rowsize - boundary is 32 */ + /* uint32_t rowsize = 4 * static_cast( + ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 + );*/ + + /* if height is positive the y-coordinates are mirrored */ + /* if (m_bitmap->getInfoHeader().biHeight > 0) + y = m_bitmap->getInfoHeader().biHeight - y - 1; + uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); + + /* boundary check */ + /* if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) + throw PixelFormatError("Pixel position is out of range."); + + /* get pixel */ +/* try + { + pixel[0] = boost::numeric_cast(*(m_bitmap->getPixelData() + offset + 2)); + pixel[1] = boost::numeric_cast(*(m_bitmap->getPixelData() + offset + 1)); + pixel[2] = boost::numeric_cast(*(m_bitmap->getPixelData() + offset)); + } + catch(boost::numeric::bad_numeric_cast& ex) + { + throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); + }*/ +} + +void CPixelFormat_Indexed8::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) +{ + /* + * pixel[0] ... red + * pixel[1] ... green + * pixel[2] ... blue + */ +/* if (m_bitmap->getPixelData() == NULL) + throw PixelFormatError("No pixelbuffer allocated."); + + /* calc rowsize - boundary is 32 */ + /* uint32_t rowsize = 4 * static_cast( + ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 + ); + + /* if height is positive the y-coordinates are mirrored */ + /* if (m_bitmap->getInfoHeader().biHeight > 0) + y = m_bitmap->getInfoHeader().biHeight - y - 1; + uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); + + /* boundary check */ + /* if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) + throw PixelFormatError("Pixel position is out of range."); + + /* convert color values to correct types */ + /*uint8_t data[3]; + try + { + data[0] = boost::numeric_cast(pixel[2]); + data[1] = boost::numeric_cast(pixel[1]); + data[2] = boost::numeric_cast(pixel[0]); + } + catch(boost::numeric::bad_numeric_cast& ex) + { + throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); + } + + copy(data, data + 3, m_bitmap->getPixelData() + offset); +*/} + +/* vim: set et sw=2 ts=2: */ -- cgit v1.2.3