public static int MakeMask(bool r, bool g, bool b, bool a) { int res = 0; if (r) res |= 0x1; if (g) res |= 0x2; if (b) res |= 0x4; if (a) res |= 0x8; return res; }