Surface8u colorizeBodyIndex( const Channel8u& bodyIndexChannel ) { Surface8u surface; if ( bodyIndexChannel ) { surface = Surface8u( bodyIndexChannel.getWidth(), bodyIndexChannel.getHeight(), true, SurfaceChannelOrder::RGBA ); Channel8u::ConstIter iterChannel = bodyIndexChannel.getIter(); Surface8u::Iter iterSurface = surface.getIter(); while ( iterChannel.line() && iterSurface.line() ) { while ( iterChannel.pixel() && iterSurface.pixel() ) { size_t index = (size_t)iterChannel.v(); ColorA8u color( getBodyColor( index ), 0xFF ); if ( index == 0 || index > BODY_COUNT ) { color.a = 0x00; } iterSurface.r() = color.r; iterSurface.g() = color.g; iterSurface.b() = color.b; iterSurface.a() = color.a; } } } return surface; }