MCPcopy Create free account
hub / github.com/carbonengine/trinity / IsPixelOpaque

Method IsPixelOpaque

trinity/Resources/Tr2ImageRes.cpp:65–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65bool 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
92Color Tr2ImageRes::GetPixelColor( int x, int y ) const
93{

Callers

nothing calls this directly

Calls 3

GetFormatMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected