AdvancedLauncher.Tools.Imaging.Utilities.GetColorFrom2Bytes C# (CSharp) Метод

GetColorFrom2Bytes() статический приватный Метод

Reads ARGB values from the 16 bits of two given Bytes in a 1555 format.
Gets the ARGB values from the 16 bits in the two bytes based on the below diagram | BYTE 1 | BYTE 2 | | A RRRRR GG | GGG BBBBB |
static private GetColorFrom2Bytes ( byte one, byte two ) : Color
one byte The first Byte.
two byte The Second Byte.
Результат Color
        internal static Color GetColorFrom2Bytes(byte one, byte two)
        {
            // get the 5 bits used for the RED value from the first byte
            int r1 = Utilities.GetBits(one, 2, 5);
            int r = r1 << 3;

            // get the two high order bits for GREEN from the from the first byte
            int bit = Utilities.GetBits(one, 0, 2);
            // shift bits to the high order
            int g1 = bit << 6;

            // get the 3 low order bits for GREEN from the from the second byte
            bit = Utilities.GetBits(two, 5, 3);
            // shift the low order bits
            int g2 = bit << 3;
            // add the shifted values together to get the full GREEN value
            int g = g1 + g2;

            // get the 5 bits used for the BLUE value from the second byte
            int b1 = Utilities.GetBits(two, 0, 5);
            int b = b1 << 3;

            // get the 1 bit used for the ALPHA value from the first byte
            int a1 = Utilities.GetBits(one, 7, 1);
            int a = a1 * 255;

            // return the resulting Color
            return Color.FromArgb(a, r, g, b);
        }