creating a mask for a color (uint vs int)

  • Thread starter Thread starter ivan.svaljek
  • Start date Start date
I

ivan.svaljek

When i try to use a blue mask for a random color like this:

Color.FromArgb( myrand.next() & 0xff0000ff )

I get an error: 0xff0000ff can't be converted to int.

Apparently maximum value for int32 is 7fffffff, so how am I to set the
alpha part to ff ?
 
When i try to use a blue mask for a random color like this:
Color.FromArgb( myrand.next() & 0xff0000ff )

I get an error: 0xff0000ff can't be converted to int.

You can cast to int in an unchecked context:

unchecked((int)0xff0000ff)


Mattias
 
Back
Top