Axiom.Media.DDSCodec.ConvertPixelFormat C# (CSharp) Method

ConvertPixelFormat() private method

private ConvertPixelFormat ( UInt32 rgbBits, UInt32 rMask, UInt32 gMask, UInt32 bMask, UInt32 aMask ) : PixelFormat
rgbBits System.UInt32
rMask System.UInt32
gMask System.UInt32
bMask System.UInt32
aMask System.UInt32
return PixelFormat
		private PixelFormat ConvertPixelFormat(UInt32 rgbBits, UInt32 rMask, UInt32 gMask, UInt32 bMask, UInt32 aMask)
		{

			// General search through pixel formats
			for ( int i = (int)PixelFormat.Unknown + 1; i < (int)PixelFormat.Count; ++i )
			{
				PixelFormat pf = (PixelFormat)( i );
				if ( PixelUtil.GetNumElemBits( pf ) == rgbBits )
				{
					UInt32[] testMasks = PixelUtil.GetBitMasks( pf );
					int[] 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" );
		}