summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixelformat_indexed8.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ue2/imgsynth2/cpixelformat_indexed8.cpp')
-rw-r--r--ue2/imgsynth2/cpixelformat_indexed8.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/ue2/imgsynth2/cpixelformat_indexed8.cpp b/ue2/imgsynth2/cpixelformat_indexed8.cpp
index c62a1ba..546daaf 100644
--- a/ue2/imgsynth2/cpixelformat_indexed8.cpp
+++ b/ue2/imgsynth2/cpixelformat_indexed8.cpp
@@ -10,32 +10,28 @@
10 10
11using namespace std; 11using namespace std;
12 12
13void CPixelFormat_Indexed8::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) 13void CPixelFormat_Indexed8::getPixel(RGBPIXEL& pixel, uint32_t x, uint32_t y)
14{ 14{
15 /* 15#if 0
16 * pixel[0] ... red 16 if (m_bitmap->getPixelData() == NULL)
17 * pixel[1] ... green 17 throw PixelFormatError("No pixelbuffer allocated.");
18 * pixel[2] ... blue
19 */
20 // if (m_bitmap->getPixelData() == NULL)
21 // throw PixelFormatError("No pixelbuffer allocated.");
22 18
23 /* calc rowsize - boundary is 32 */ 19 /* calc rowsize - boundary is 32 */
24 /* uint32_t rowsize = 4 * static_cast<uint32_t>( 20 uint32_t rowsize = 4 * static_cast<uint32_t>(
25 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 21 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32
26 );*/ 22 );*/
27 23
28 /* if height is positive the y-coordinates are mirrored */ 24 /* if height is positive the y-coordinates are mirrored */
29 /* if (m_bitmap->getInfoHeader().biHeight > 0) 25 if (m_bitmap->getInfoHeader().biHeight > 0)
30 y = m_bitmap->getInfoHeader().biHeight - y - 1; 26 y = m_bitmap->getInfoHeader().biHeight - y - 1;
31 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 27 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
32 28
33 /* boundary check */ 29 /* boundary check */
34 /* if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 30 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage)
35 throw PixelFormatError("Pixel position is out of range."); 31 throw PixelFormatError("Pixel position is out of range.");
36 32
37 /* get pixel */ 33 /* get pixel */
38/* try 34 try
39 { 35 {
40 pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2)); 36 pixel[0] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 2));
41 pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1)); 37 pixel[1] = boost::numeric_cast<uint32_t>(*(m_bitmap->getPixelData() + offset + 1));
@@ -44,35 +40,32 @@ void CPixelFormat_Indexed8::getPixel(uint32_t *pixel, uint32_t x, uint32_t y)
44 catch(boost::numeric::bad_numeric_cast& ex) 40 catch(boost::numeric::bad_numeric_cast& ex)
45 { 41 {
46 throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what())); 42 throw PixelFormatError("Unable to convert pixelcolor to correct size: " + string(ex.what()));
47 }*/ 43 }
44#endif
48} 45}
49 46
50void CPixelFormat_Indexed8::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) 47void CPixelFormat_Indexed8::setPixel(const RGBPIXEL& pixel, uint32_t x, uint32_t y)
51{ 48{
52 /* 49#if 0
53 * pixel[0] ... red 50 if (m_bitmap->getPixelData() == NULL)
54 * pixel[1] ... green
55 * pixel[2] ... blue
56 */
57/* if (m_bitmap->getPixelData() == NULL)
58 throw PixelFormatError("No pixelbuffer allocated."); 51 throw PixelFormatError("No pixelbuffer allocated.");
59 52
60 /* calc rowsize - boundary is 32 */ 53 /* calc rowsize - boundary is 32 */
61 /* uint32_t rowsize = 4 * static_cast<uint32_t>( 54 uint32_t rowsize = 4 * static_cast<uint32_t>(
62 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 55 ((getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32
63 ); 56 );
64 57
65 /* if height is positive the y-coordinates are mirrored */ 58 /* if height is positive the y-coordinates are mirrored */
66 /* if (m_bitmap->getInfoHeader().biHeight > 0) 59 if (m_bitmap->getInfoHeader().biHeight > 0)
67 y = m_bitmap->getInfoHeader().biHeight - y - 1; 60 y = m_bitmap->getInfoHeader().biHeight - y - 1;
68 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 61 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
69 62
70 /* boundary check */ 63 /* boundary check */
71 /* if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 64 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage)
72 throw PixelFormatError("Pixel position is out of range."); 65 throw PixelFormatError("Pixel position is out of range.");
73 66
74 /* convert color values to correct types */ 67 /* convert color values to correct types */
75 /*uint8_t data[3]; 68 uint8_t data[3];
76 try 69 try
77 { 70 {
78 data[0] = boost::numeric_cast<uint8_t>(pixel[2]); 71 data[0] = boost::numeric_cast<uint8_t>(pixel[2]);
@@ -85,6 +78,7 @@ void CPixelFormat_Indexed8::setPixel(const uint32_t *pixel, uint32_t x, uint32_t
85 } 78 }
86 79
87 copy(data, data + 3, m_bitmap->getPixelData() + offset); 80 copy(data, data + 3, m_bitmap->getPixelData() + offset);
88*/} 81#endif
82}
89 83
90/* vim: set et sw=2 ts=2: */ 84/* vim: set et sw=2 ts=2: */