Having an object, for example:

SystemDrawing.Color color=SystemDrawing.Color.Blue; 

equate it to (255<<24|122<<8) .
Or, perform a bitwise equalization of AND or OR (& |), for example:

 color &=255<<24|122<<8; color |= 255<<24|122<<8 

Or change any bit, for example:

  color = color & (~0 ^ 1<<16); 

Well, or what method to apply to the bits of the object in c #, without using the methods of the BitConverter class? Well, or create with the object written by me?

  • @SuchCoder, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Vitalina

1 answer 1

Color is a structure with fields A, R, G, and B. It also has methods ToArgb and FromArgb. Thus, if you need to invert a color, for example, you can do this:

 Color color = Color.Blue; Color inverted = Color.FromArgb(color.R ^ 0xFF, color.G ^ 0xFF, color.B ^ 0xFF); // или так Color inverted = Color.FromArgb(color.ToArgb() ^ 0xFFFFFF);