From bca08c6de2b156cbec90944c809e5e7faecd231d Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 1 May 2009 20:33:33 +0200 Subject: cwindowsbitmap: seek to bitmap data cpixmap: use copy() instead of accessing array via indices --- ue2/imgsynth2/cbitmap.cpp | 1 + ue2/imgsynth2/cpixelformat_indexed8.cpp | 2 +- ue2/imgsynth2/cpixelformat_indexed8.h | 6 +++--- ue2/imgsynth2/cpixmap.cpp | 9 ++++----- ue2/imgsynth2/cwindowsbitmap.cpp | 1 + 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'ue2/imgsynth2') diff --git a/ue2/imgsynth2/cbitmap.cpp b/ue2/imgsynth2/cbitmap.cpp index c2cd99a..2e135db 100644 --- a/ue2/imgsynth2/cbitmap.cpp +++ b/ue2/imgsynth2/cbitmap.cpp @@ -105,6 +105,7 @@ void CBitmap::fillrect(std::list params) pixel.blue = pparams[6]; /* call setPixel for every pixel in the rectangel */ + /* NOTE: maybe use fill() here? */ for(uint32_t i = pparams[0]; i < pparams[2] + pparams[0]; i++) { for(uint32_t j = pparams[1]; j < pparams[3] + pparams[1]; j++) diff --git a/ue2/imgsynth2/cpixelformat_indexed8.cpp b/ue2/imgsynth2/cpixelformat_indexed8.cpp index 546daaf..6453fad 100644 --- a/ue2/imgsynth2/cpixelformat_indexed8.cpp +++ b/ue2/imgsynth2/cpixelformat_indexed8.cpp @@ -1,7 +1,7 @@ /** * @module CPixelFormat_Indexed8 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) - * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. + * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps TODO. * @date 18.04.2009 */ diff --git a/ue2/imgsynth2/cpixelformat_indexed8.h b/ue2/imgsynth2/cpixelformat_indexed8.h index 3b29bf8..f1bb0f0 100644 --- a/ue2/imgsynth2/cpixelformat_indexed8.h +++ b/ue2/imgsynth2/cpixelformat_indexed8.h @@ -1,7 +1,7 @@ /** * @module cpixelformat_bgr24 * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) - * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. + * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps TODO. * @date 18.04.2009 */ @@ -14,7 +14,7 @@ /** * @class CPixelFormat_Indexed8 - * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps. + * @brief Implementation of CPixelFormat handling 24bit color Windows Bitmaps TODO. * * On error CPixelFormat::PixelFormatError is thrown. */ @@ -24,7 +24,7 @@ class CPixelFormat_Indexed8 : public CPixelFormat /** * @method CPixelFormat_Indexed8 * @brief Default ctor - * @param bitmap pointer to CBitmap instance + * @param pixmap pointer to CPixmap instance * @return - * @globalvars none * @exception none diff --git a/ue2/imgsynth2/cpixmap.cpp b/ue2/imgsynth2/cpixmap.cpp index d3e10d8..9e03d86 100644 --- a/ue2/imgsynth2/cpixmap.cpp +++ b/ue2/imgsynth2/cpixmap.cpp @@ -272,12 +272,11 @@ void CPixmap::write(std::ofstream& out) } /* pixel data */ - //TODO: better via copy? for (uint32_t y = 0; y < getHeight(); y++) { out << "\""; - for (uint32_t x = 0; x < getWidth(); x++) - out << m_pixeldata[y * getWidth() + x]; + uint32_t offset = y * getWidth(); + copy(m_pixeldata + offset, m_pixeldata + offset + getWidth(), ostream_iterator(out)); out << "\"," << endl; } @@ -297,8 +296,8 @@ void CPixmap::dump(std::ostream& out) cout << "[XPM Pixel Data]" << endl; for (uint32_t y = 0; y < getHeight(); y++) { - for (uint32_t x = 0; x < getWidth(); x++) - out << m_pixeldata[y * getWidth() + x]; + uint32_t offset = y * getWidth(); + copy(m_pixeldata + offset, m_pixeldata + offset + getWidth(), ostream_iterator(cout)); out << endl; } out << endl; diff --git a/ue2/imgsynth2/cwindowsbitmap.cpp b/ue2/imgsynth2/cwindowsbitmap.cpp index ebbdd4c..ddacab9 100644 --- a/ue2/imgsynth2/cwindowsbitmap.cpp +++ b/ue2/imgsynth2/cwindowsbitmap.cpp @@ -58,6 +58,7 @@ void CWindowsBitmap::read(std::ifstream& in) if (m_pixeldata != NULL) delete[] m_pixeldata; m_pixeldata = new uint8_t[m_infoheader.biSizeImage]; + in.seekg(m_fileheader.bfOffBits); in.read(reinterpret_cast(m_pixeldata), m_infoheader.biSizeImage); } -- cgit v1.2.3