Y
Yaniv
Hi
How can I convert Uint32 variable to System.drawing.color ??
Thanks in advanced
Yaniv
How can I convert Uint32 variable to System.drawing.color ??
Thanks in advanced
Yaniv
Yaniv said:Hi
How can I convert Uint32 variable to System.drawing.color ??
Thanks in advanced
Yaniv
Göran Andersson said:Yes, you are right. I tried this in VB, and it won't convert an
UInt32 to an Int32 without checking for overflow.
It works just fine
in C#. Some say that the CType function in VB is the same as casting
in C#, but obviously it isn't.
I also tried CInt, Convert.ToInt32 and DirectCast, but they all do
overflow checking.
I guess you have to chop up the value in pieces to handle it:
Dim alpha As Integer = colorCode >> 24
Dim code As Integer = colorCode And &HFFFFFF
Dim c As Color = Color.FromArgb(alpha, Color.FromArgb(code))
or:
Dim alpha As Integer = colorCode >> 24
Dim red As Integer = (colorCode >> 16) And &HFF
Dim green As Integer = (colorCode >> 8) And &HFF
Dim blue As Integer = colorCode And &HFF
Dim c As Color = Color.FromArgb(alpha, red, green, blue)
Hi
How can I convert Uint32 variable to System.drawing.color ??
Thanks in advanced
Yaniv