xor color calculation

  • Thread starter Thread starter Christopher Ireland
  • Start date Start date
C

Christopher Ireland

Hi -

I'm trying to calculate the xor color of any given system color. I've tried
the following:

int xorColor = anyColor.ToArgb();
//xorColor = ~xorColor & 16777215;
//xorColor = -1 ^ xorColor;

But neither of these two calculations (which are the same anyway?) returns
correct xor colors for all permutations of anyColor. Can anybody please give
me a hand?

Many thanks.

Christopher Ireland.
 
Hi Christopher,
Hi -

I'm trying to calculate the xor color of any given system color. I've tried
the following:

int xorColor = anyColor.ToArgb();
//xorColor = ~xorColor & 16777215;
//xorColor = -1 ^ xorColor;

But neither of these two calculations (which are the same anyway?) returns
correct xor colors for all permutations of anyColor. Can anybody please give
me a hand?

Try this:

xorColor=00xffffff ^ xorColor;

// xorColor=00xffffff & xorColor; // may be usefull

If it will not work i think that you shold do XOR on every color element
(R, G, B) and then join those with:

Color.FromArgb(r, g, b)

Regards

Marcin
 
Hi Christopher,

what do you mean by "XOR" colour? Generally when a colour it is XORed
it is in relation to other colours.

eg.
int specificColor = 0x....;
int anyColor = 0x....;

int xorColor = specificColor ^ anyColor;

anyColor = xorColor ^ color;

If I have understood you correctly there is no single XOR value per
colour that can be used with all colours.
 
Back
Top