summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixelformat_bgr555.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ue2/imgsynth2/cpixelformat_bgr555.cpp')
-rw-r--r--ue2/imgsynth2/cpixelformat_bgr555.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/ue2/imgsynth2/cpixelformat_bgr555.cpp b/ue2/imgsynth2/cpixelformat_bgr555.cpp
index 4a3c833..19c98a8 100644
--- a/ue2/imgsynth2/cpixelformat_bgr555.cpp
+++ b/ue2/imgsynth2/cpixelformat_bgr555.cpp
@@ -11,6 +11,22 @@
11 11
12using namespace std; 12using namespace std;
13 13
14/* TODO */
15void CPixelFormat_BGR555::getPixel(uint32_t *pixel, uint32_t x, uint32_t y)
16{
17 /*
18 * pixel[0] ... red
19 * pixel[1] ... green
20 * pixel[2] ... blue
21 */
22 if (m_bitmap->getPixelData() == NULL)
23 throw PixelFormatError("No pixelbuffer allocated.");
24
25 throw PixelFormatError("NOT IMPLEMENTED");
26}
27
28/*----------------------------------------------------------------------------*/
29
14void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y) 30void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y)
15{ 31{
16 /* 32 /*
@@ -24,16 +40,16 @@ void CPixelFormat_BGR555::setPixel(const uint32_t *pixel, uint32_t x, uint32_t y
24 40
25 /* calc rowsize - boundary is 32 */ 41 /* calc rowsize - boundary is 32 */
26 uint32_t rowsize = 4 * static_cast<uint32_t>( 42 uint32_t rowsize = 4 * static_cast<uint32_t>(
27 ((CPixelFormat_BGR555::getBitCount() * abs(m_bitmap->getInfoHeader().biWidth)) + 31) / 32 43 ((getBitCount() * m_bitmap->getWidth()) + 31) / 32
28 ); 44 );
29 45
30 /* if height is positive the y-coordinates are mirrored */ 46 /* if the y-coordinates are mirrored */
31 if (m_bitmap->getInfoHeader().biHeight > 0) 47 if (m_bitmap->isMirrored())
32 y = m_bitmap->getInfoHeader().biHeight - y - 1; 48 y = m_bitmap->getHeight() - y - 1;
33 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32); 49 uint32_t offset = y * rowsize + x * (4 * getBitCount() / 32);
34 50
35 /* boundary check */ 51 /* boundary check */
36 if (offset + getBitCount()/8 > m_bitmap->getInfoHeader().biSizeImage) 52 if (offset + getBitCount()/8 > m_bitmap->getPixelDataSize())
37 throw PixelFormatError("Pixel position is out of range."); 53 throw PixelFormatError("Pixel position is out of range.");
38 54
39 /* convert color values to correct types */ 55 /* convert color values to correct types */