diff options
| author | manuel <manuel@nc8430.lan> | 2009-05-02 17:28:21 +0200 |
|---|---|---|
| committer | manuel <manuel@nc8430.lan> | 2009-05-02 17:28:21 +0200 |
| commit | 5c4506a8c5ee1a82268146007619b09e980a7a57 (patch) | |
| tree | c21bb83bdf7c87b7c9f9693cd4fcd43212ae4be2 /ue2/imgsynth2/cpixelformat_indexed8.cpp | |
| parent | bcadfa267f976fe9f29afa50a635cbe3ea174e38 (diff) | |
| download | ooprog-5c4506a8c5ee1a82268146007619b09e980a7a57.tar.gz ooprog-5c4506a8c5ee1a82268146007619b09e980a7a57.tar.bz2 ooprog-5c4506a8c5ee1a82268146007619b09e980a7a57.zip | |
add some assert() to make tutor happy
Diffstat (limited to 'ue2/imgsynth2/cpixelformat_indexed8.cpp')
| -rw-r--r-- | ue2/imgsynth2/cpixelformat_indexed8.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ue2/imgsynth2/cpixelformat_indexed8.cpp b/ue2/imgsynth2/cpixelformat_indexed8.cpp index 21b0988..d92ae9f 100644 --- a/ue2/imgsynth2/cpixelformat_indexed8.cpp +++ b/ue2/imgsynth2/cpixelformat_indexed8.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include <boost/numeric/conversion/cast.hpp> | 8 | #include <boost/numeric/conversion/cast.hpp> |
| 9 | #include <assert.h> | ||
| 9 | #include "cpixelformat_indexed8.h" | 10 | #include "cpixelformat_indexed8.h" |
| 10 | 11 | ||
| 11 | using namespace std; | 12 | using namespace std; |
| @@ -16,6 +17,7 @@ void CPixelFormat_Indexed8::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) | |||
| 16 | throw PixelFormatError("No pixelbuffer allocated."); | 17 | throw PixelFormatError("No pixelbuffer allocated."); |
| 17 | if (m_bitmap->getColorTable().size() == 0) | 18 | if (m_bitmap->getColorTable().size() == 0) |
| 18 | return; | 19 | return; |
| 20 | assert(m_bitmap->getPixelDataSize() > 0); | ||
| 19 | 21 | ||
| 20 | uint32_t offset = y * m_bitmap->getWidth() + x; | 22 | uint32_t offset = y * m_bitmap->getWidth() + x; |
| 21 | 23 | ||
| @@ -40,8 +42,10 @@ void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t | |||
| 40 | { | 42 | { |
| 41 | if (m_bitmap->getPixelData() == NULL) | 43 | if (m_bitmap->getPixelData() == NULL) |
| 42 | throw PixelFormatError("No pixelbuffer allocated."); | 44 | throw PixelFormatError("No pixelbuffer allocated."); |
| 45 | /* if colortable is empty there are no pixels */ | ||
| 43 | if (m_bitmap->getColorTable().size() == 0) | 46 | if (m_bitmap->getColorTable().size() == 0) |
| 44 | return; | 47 | return; |
| 48 | assert(m_bitmap->getPixelDataSize() > 0); | ||
| 45 | 49 | ||
| 46 | uint32_t offset = y * m_bitmap->getWidth() + x; | 50 | uint32_t offset = y * m_bitmap->getWidth() + x; |
| 47 | 51 | ||
| @@ -60,7 +64,7 @@ void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t | |||
| 60 | } | 64 | } |
| 61 | 65 | ||
| 62 | uint32_t index = (*it).first; | 66 | uint32_t index = (*it).first; |
| 63 | /* need to get a new character for our color */ | 67 | /* need to get a new entry for our color */ |
| 64 | if (it == m_bitmap->getColorTable().end()) | 68 | if (it == m_bitmap->getColorTable().end()) |
| 65 | { | 69 | { |
| 66 | index = (*it).first + 1; | 70 | index = (*it).first + 1; |
