Alexandria.Platforms.NintendoDS.Extensions.ReadNDSColor C# (CSharp) Метод

ReadNDSColor() публичный статический Метод

Read a two-byte color code for the Nintendo DS. They are stored as unsigned shorts, 5 bits per component, with an optional alpha bit.
public static ReadNDSColor ( this reader, bool useAlpha = false, bool forceTransparent = false ) : Color
reader this What to read the color from.
useAlpha bool Whether to use the alpha bit. The default is false.
forceTransparent bool Whether to force a transparent color. The default is false.
Результат Color
        public static Color ReadNDSColor(this BinaryReader reader, bool useAlpha = false, bool forceTransparent = false)
        {
            ushort value = reader.ReadUInt16();
            int alpha = forceTransparent ? 0 : useAlpha ? (value >> 15) * 255 : 255;
            int red = (value & 31) * 255 / 31;
            int green = ((value >> 5) & 31) * 255 / 31;
            int blue = ((value >> 10) & 31) * 255 / 31;
            return Color.FromArgb(alpha, red, green, blue);
        }