In case you do know about the actual color format of the input data you should consider to use Graphics::ColorMask and the templated Graphics::colorToRGB from graphics/colormasks.h (this might be useful elsewhere too).