From b22395ec4de60326eb629df882b4b8781dbca15c Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 1 May 2009 14:54:45 +0200 Subject: - removed runtime generated output files - implemented brightness() - implemented invert() - implemented getPixel in CPixelFormat_BGR24 and CPixelFormat_BGR555 --- ue2/imgsynth2/cpixelformat_bgr24.cpp | 37 +++++++++++------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'ue2/imgsynth2/cpixelformat_bgr24.cpp') diff --git a/ue2/imgsynth2/cpixelformat_bgr24.cpp b/ue2/imgsynth2/cpixelformat_bgr24.cpp index 4567ce6..e7476d7 100644 --- a/ue2/imgsynth2/cpixelformat_bgr24.cpp +++ b/ue2/imgsynth2/cpixelformat_bgr24.cpp @@ -7,17 +7,12 @@ #include #include "cpixelformat_bgr24.h" +#include "cbitmap.h" using namespace std; -/* TODO */ -void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) +void CPixelFormat_BGR24::getPixel(RGBPIXEL& 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."); @@ -36,25 +31,15 @@ void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) 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())); - } + pixel.red = *(m_bitmap->getPixelData() + offset + 2); + pixel.green = *(m_bitmap->getPixelData() + offset + 1); + pixel.blue = *(m_bitmap->getPixelData() + offset); } -void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) +/*----------------------------------------------------------------------------*/ + +void CPixelFormat_BGR24::setPixel(const RGBPIXEL& 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."); @@ -76,9 +61,9 @@ void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) 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]); + data[0] = boost::numeric_cast(pixel.blue); + data[1] = boost::numeric_cast(pixel.green); + data[2] = boost::numeric_cast(pixel.red); } catch(boost::numeric::bad_numeric_cast& ex) { -- cgit v1.2.3