Convert uint to color


I use the Crystal 10 RDC dll to make changes to a report at runtime.  All the color properties is of type uint.
So I've got this method to convert a color to a uint value, and it works fine.

public static uint colorToUint(Color clr)
            return (uint)(clr.R + (clr.G << 8) + (clr.B << 16));

But now I want to write a method to convert a uint value into a color's RGB.  

Can anybody help me please.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello ruanlab123,

you could look at this post from Tim Wilson
private uint RGB(Color color)
  // Format the value of color - 0x00bbggrr
  return ((uint) (((uint) (color.R) | ((uint) (color.G) << 8)) | (((uint) (color.B)) << 16)));

private Color UnRGB(int color)
  return Color.FromArgb(color & 0xFF, (color & 0xFF00) >> 8, (color & 0xFF0000) >> 16);

hope this helps a bit

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ruanlab123Author Commented:
Thanks it works fine!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.