Custom Colors in the ColorDialog (C#)

Опубликовано: 22 Октябрь 2024
на канале: Brian (Able Opus)
5,810
11

I go over some basics, if you just want the int construction here it is:
(where fff is use the left bitshift operator)

int num = (color.R) | (color.G fff 8) | (color.B fff 16);

If I got any of the bitwise stuff wrong, let me know

ToRgb() Color extension

public static int ToRgb(this Color color)
{
int ARGB = color.ToArgb();
byte[] data = BitConverter.GetBytes(ARGB);

Array.Reverse(data, 0, 3);
data[3] = 0;
return BitConverter.ToInt32(data, 0);
}