[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2474
  • Last Modified:

Convert uint to color

Hi

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.

Thanks
0
ruanlab123
Asked:
ruanlab123
1 Solution
 
bruintjeCommented:
Hello ruanlab123,

you could look at this post from Tim Wilson
source: http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/msg/4184603f0ffd2578?hl=en&
----------
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
bruintje
0
 
ruanlab123Author Commented:
Thanks it works fine!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now