summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixelformat_bgr24.cpp
diff options
context:
space:
mode:
authormanuel <manuel@clan-server.at>2009-04-28 18:32:15 +0200
committermanuel <manuel@clan-server.at>2009-04-28 18:32:15 +0200
commit5f499a8233c7bb68b52b8fdeddac9a06061ea4d7 (patch)
tree894f18cf427eb83c6463a92da76f4a3808a8187c /ue2/imgsynth2/cpixelformat_bgr24.cpp
parentd7893436cefc6b3cef78ad765dba4fa1740d0f15 (diff)
downloadooprog-5f499a8233c7bb68b52b8fdeddac9a06061ea4d7.tar.gz
ooprog-5f499a8233c7bb68b52b8fdeddac9a06061ea4d7.tar.bz2
ooprog-5f499a8233c7bb68b52b8fdeddac9a06061ea4d7.zip
Moved a lot of stuff around to get abstract cbitmap working
Diffstat (limited to 'ue2/imgsynth2/cpixelformat_bgr24.cpp')
-rw-r--r--ue2/imgsynth2/cpixelformat_bgr24.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/ue2/imgsynth2/cpixelformat_bgr24.cpp b/ue2/imgsynth2/cpixelformat_bgr24.cpp
index cc02dcc..4567ce6 100644
--- a/ue2/imgsynth2/cpixelformat_bgr24.cpp
+++ b/ue2/imgsynth2/cpixelformat_bgr24.cpp
@@ -10,6 +10,7 @@
10 10
11using namespace std; 11using namespace std;
12 12
13/* TODO */
13void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) 14void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y)
14{ 15{
15 /* 16 /*
@@ -22,16 +23,16 @@ void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y)
22 23
23 /* calc rowsize - boundary is 32 */ 24 /* calc rowsize - boundary is 32 */
24 uint32_t rowsize = 4 * static_cast<uint32_t>( 25 uint32_t rowsize = 4 * static_cast<uint32_t>(
25 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 26 ((getBitCount() * m_bitmap->getWidth()) + 31) / 32
26 ); 27 );
27 28
28 /* if height is positive the y-coordinates are mirrored */ 29 /* if the y-coordinates are mirrored */
29 if (m_bitmap->getInfoHeader().biHeight > 0) 30 if (m_bitmap->isMirrored())
30 y = m_bitmap->getInfoHeader().biHeight - y - 1; 31 y = m_bitmap->getHeight() - y - 1;
31 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 32 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
32 33
33 /* boundary check */ 34 /* boundary check */
34 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 35 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
35 throw PixelFormatError("Pixel position is out of range."); 36 throw PixelFormatError("Pixel position is out of range.");
36 37
37 /* get pixel */ 38 /* get pixel */
@@ -59,16 +60,16 @@ void CPixelFormat_BGR24::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y)
59 60
60 /* calc rowsize - boundary is 32 */ 61 /* calc rowsize - boundary is 32 */
61 uint32_t rowsize = 4 * static_cast<uint32_t>( 62 uint32_t rowsize = 4 * static_cast<uint32_t>(
62 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 63 ((getBitCount() * m_bitmap->getWidth()) + 31) / 32
63 ); 64 );
64 65
65 /* if height is positive the y-coordinates are mirrored */ 66 /* if the y-coordinates are mirrored */
66 if (m_bitmap->getInfoHeader().biHeight > 0) 67 if (m_bitmap->isMirrored())
67 y = m_bitmap->getInfoHeader().biHeight - y - 1; 68 y = m_bitmap->getHeight() - y - 1;
68 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 69 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
69 70
70 /* boundary check */ 71 /* boundary check */
71 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 72 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
72 throw PixelFormatError("Pixel position is out of range."); 73 throw PixelFormatError("Pixel position is out of range.");
73 74
74 /* convert color values to correct types */ 75 /* convert color values to correct types */