diff options
Diffstat (limited to 'ue2/imgsynth2/cpixelformat_bgr24.cpp')
| -rw-r--r-- | ue2/imgsynth2/cpixelformat_bgr24.cpp | 21 |
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 | ||
| 11 | using namespace std; | 11 | using namespace std; |
| 12 | 12 | ||
| 13 | /* TODO */ | ||
| 13 | void CPixelFormat_BGR24::getPixel(uint32_t *pixel, uint32_t x, uint32_t y) | 14 | void 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 */ |
