private PixelFormat _convertPixelFormat(int rgbBits, int rMask, int gMask, int bMask, int aMask)
{
// General search through pixel formats
for (var i = (int)PixelFormat.Unknown + 1; i < (int)PixelFormat.Count; ++i)
{
var pf = (PixelFormat)i;
if (PixelUtil.GetNumElemBits(pf) == rgbBits)
{
var testMasks = PixelUtil.GetBitMasks(pf);
var testBits = PixelUtil.GetBitDepths(pf);
if (testMasks[0] == rMask && testMasks[1] == gMask && testMasks[2] == bMask &&
// for alpha, deal with 'X8' formats by checking bit counts
(testMasks[3] == aMask || (aMask == 0 && testBits[3] == 0)))
{
return(pf);
}
}
}
throw new AxiomException("Cannot determine pixel format");
}