diff options
| author | manuel <manuel@nc8430.lan> | 2009-05-01 14:54:45 +0200 |
|---|---|---|
| committer | manuel <manuel@nc8430.lan> | 2009-05-01 14:54:45 +0200 |
| commit | b22395ec4de60326eb629df882b4b8781dbca15c (patch) | |
| tree | b04e7a01d3e50c7d366059517fae249381c7540c /ue2/imgsynth2/cpixelformat_bgr24.cpp | |
| parent | cfd4f77988cf12106e22e52fba6c1b5672a06162 (diff) | |
| download | ooprog-b22395ec4de60326eb629df882b4b8781dbca15c.tar.gz ooprog-b22395ec4de60326eb629df882b4b8781dbca15c.tar.bz2 ooprog-b22395ec4de60326eb629df882b4b8781dbca15c.zip | |
- removed runtime generated output files
- implemented brightness()
- implemented invert()
- implemented getPixel in CPixelFormat_BGR24 and CPixelFormat_BGR555
Diffstat (limited to 'ue2/imgsynth2/cpixelformat_bgr24.cpp')
| -rw-r--r-- | ue2/imgsynth2/cpixelformat_bgr24.cpp | 37 |
1 files changed, 11 insertions, 26 deletions
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 @@ | |||
| 7 | 7 | ||
| 8 | #include <boost/numeric/conversion/cast.hpp> | 8 | #include <boost/numeric/conversion/cast.hpp> |
| 9 | #include "cpixelformat_bgr24.h" | 9 | #include "cpixelformat_bgr24.h" |
| 10 | #include "cbitmap.h" | ||
| 10 | 11 | ||
| 11 | using namespace std; | 12 | using namespace std; |
| 12 | 13 | ||
| 13 | /* TODO */ | 14 | void CPixelFormat_BGR24::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) |
| 14 | void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | ||
| 15 | { | 15 | { |
| 16 | /* | ||
| 17 | * pixel[0] ... red | ||
| 18 | * pixel[1] ... green | ||
| 19 | * pixel[2] ... blue | ||
| 20 | */ | ||
| 21 | if (m_bitmap->getPixelData() == NULL) | 16 | if (m_bitmap->getPixelData() == NULL) |
| 22 | throw PixelFormatError("No pixelbuffer allocated."); | 17 | throw PixelFormatError("No pixelbuffer allocated."); |
| 23 | 18 | ||
| @@ -36,25 +31,15 @@ void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | |||
| 36 | throw PixelFormatError("Pixel position is out of range."); | 31 | throw PixelFormatError("Pixel position is out of range."); |
| 37 | 32 | ||
| 38 | /* get pixel */ | 33 | /* get pixel */ |
| 39 | try | 34 | pixel.red = *(m_bitmap->getPixelData() + offset + 2); |
| 40 | { | 35 | pixel.green = *(m_bitmap->getPixelData() + offset + 1); |
| 41 | pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2)); | 36 | pixel.blue = *(m_bitmap->getPixelData() + offset); |
| 42 | pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1)); | ||
| 43 | pixel[2] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset)); | ||
| 44 | } | ||
| 45 | catch(boost::numeric::bad_numeric_cast& ex) | ||
| 46 | { | ||
| 47 | throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); | ||
| 48 | } | ||
| 49 | } | 37 | } |
| 50 | 38 | ||
| 51 | void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | 39 | /*----------------------------------------------------------------------------*/ |
| 40 | |||
| 41 | void CPixelFormat_BGR24::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y) | ||
| 52 | { | 42 | { |
| 53 | /* | ||
| 54 | * pixel[0] ... red | ||
| 55 | * pixel[1] ... green | ||
| 56 | * pixel[2] ... blue | ||
| 57 | */ | ||
| 58 | if (m_bitmap->getPixelData() == NULL) | 43 | if (m_bitmap->getPixelData() == NULL) |
| 59 | throw PixelFormatError("No pixelbuffer allocated."); | 44 | throw PixelFormatError("No pixelbuffer allocated."); |
| 60 | 45 | ||
| @@ -76,9 +61,9 @@ void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) | |||
| 76 | uint8_t data[3]; | 61 | uint8_t data[3]; |
| 77 | try | 62 | try |
| 78 | { | 63 | { |
| 79 | data[0] = boost::numeric_cast<uint8_t>(pixel[2]); | 64 | data[0] = boost::numeric_cast<uint8_t>(pixel.blue); |
| 80 | data[1] = boost::numeric_cast<uint8_t>(pixel[1]); | 65 | data[1] = boost::numeric_cast<uint8_t>(pixel.green); |
| 81 | data[2] = boost::numeric_cast<uint8_t>(pixel[0]); | 66 | data[2] = boost::numeric_cast<uint8_t>(pixel.red); |
| 82 | } | 67 | } |
| 83 | catch(boost::numeric::bad_numeric_cast& ex) | 68 | catch(boost::numeric::bad_numeric_cast& ex) |
| 84 | { | 69 | { |
