| 63 | } |
| 64 | |
| 65 | bool Tr2ImageRes::IsPixelOpaque( int x, int y ) const |
| 66 | { |
| 67 | // TODO: Support different formats |
| 68 | if( m_bitmap.GetFormat() != Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ) |
| 69 | { |
| 70 | CCP_LOGERR( "Tr2ImageRes::IsPixelOpaque currently only supports PIXEL_FORMAT_B8G8R8A8_UNORM" ); |
| 71 | return false; |
| 72 | } |
| 73 | |
| 74 | if( !m_bitmap.GetRawData() ) |
| 75 | { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | if( ( x < 0 ) || ( y < 0 ) || ( x >= int( m_bitmap.GetWidth() ) ) || ( y >= int( m_bitmap.GetHeight() ) ) ) |
| 80 | { |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | const unsigned char* p = reinterpret_cast<const unsigned char*>( m_bitmap.GetRawData() ); |
| 85 | |
| 86 | const int bytesPerPixel = 4; // only works for PIXEL_FORMAT_B8G8R8A8_UNORM, etc. |
| 87 | p += y * m_bitmap.GetWidth() * bytesPerPixel + x * bytesPerPixel; |
| 88 | |
| 89 | return p[3] > 0x7f; |
| 90 | } |
| 91 | |
| 92 | Color Tr2ImageRes::GetPixelColor( int x, int y ) const |
| 93 | { |