From 5c4506a8c5ee1a82268146007619b09e980a7a57 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 2 May 2009 17:28:21 +0200 Subject: add some assert() to make tutor happy --- ue2/imgsynth2/cpixelformat_indexed8.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ue2/imgsynth2/cpixelformat_indexed8.cpp') 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 @@ */ #include +#include #include "cpixelformat_indexed8.h" using namespace std; @@ -16,6 +17,7 @@ void CPixelFormat_Indexed8::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y) throw PixelFormatError("No pixelbuffer allocated."); if (m_bitmap->getColorTable().size() == 0) return; + assert(m_bitmap->getPixelDataSize() > 0); uint32_t offset = y * m_bitmap->getWidth() + x; @@ -40,8 +42,10 @@ void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t { if (m_bitmap->getPixelData() == NULL) throw PixelFormatError("No pixelbuffer allocated."); + /* if colortable is empty there are no pixels */ if (m_bitmap->getColorTable().size() == 0) return; + assert(m_bitmap->getPixelDataSize() > 0); uint32_t offset = y * m_bitmap->getWidth() + x; @@ -60,7 +64,7 @@ void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t } uint32_t index = (*it).first; - /* need to get a new character for our color */ + /* need to get a new entry for our color */ if (it == m_bitmap->getColorTable().end()) { index = (*it).first + 1; -- cgit v1.2.3