Q:

System.Windows.Media.Color to Java int

I'm need some way to convert a System.Windows.Media.Color to a Java int with the following format: 0x00RRGGBB in C#. Any ideas? Thanks!

A:

System.Windows.Media.Color has a property for Alpha, Red, Green and Blue.
They're all of the type "byte" (value of 0-255).
You can mash all 4 of those properties into a single unsigned 32-bit integer using some simple bit-wise operations:
public uint ConvertColorToUInt(Color color)
{
    uint value = (color.A << 24) | (color.R << 16) | (color.G << 8) | color.B;
    return value;
}

or if it needs to be a string:
public string ConvertColorToJavaString(Color color)
{
    uint value = (color.A << 24) | (color.R << 16) | (color.G << 8) | color.B;
    var javaString = string.Format("0x{0}", value.ToString("X2"))
    return javaString;
}

