From 5f499a8233c7bb68b52b8fdeddac9a06061ea4d7 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 28 Apr 2009 18:32:15 +0200 Subject: Moved a lot of stuff around to get abstract cbitmap working --- ue2/imgsynth2/cpixelformat_bgr555.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'ue2/imgsynth2/cpixelformat_bgr555.cpp') diff --git a/ue2/imgsynth2/cpixelformat_bgr555.cpp b/ue2/imgsynth2/cpixelformat_bgr555.cpp index 4a3c833..19c98a8 100644 --- a/ue2/imgsynth2/cpixelformat_bgr555.cpp +++ b/ue2/imgsynth2/cpixelformat_bgr555.cpp @@ -11,6 +11,22 @@ using namespace std; +/* TODO */ +void CPixelFormat_BGR555::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."); + + throw PixelFormatError("NOT IMPLEMENTED"); +} + +/*----------------------------------------------------------------------------*/ + void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) { /* @@ -24,16 +40,16 @@ void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y /* calc rowsize - boundary is 32 */ uint32_t rowsize = 4 * static_cast( - ((CPixelFormat_BGR555::getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 + ((getBitCount() * m_bitmap->getWidth()) + 31) / 32 ); - /* if height is positive the y-coordinates are mirrored */ - if (m_bitmap->getInfoHeader().biHeight > 0) - y = m_bitmap->getInfoHeader().biHeight - y - 1; + /* if the y-coordinates are mirrored */ + if (m_bitmap->isMirrored()) + y = m_bitmap->getHeight() - y - 1; uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); /* boundary check */ - if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) + if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize()) throw PixelFormatError("Pixel position is out of range."); /* convert color values to correct types */ -- cgit v1.2.3