By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,112 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

RGB from UINT32

P: n/a
I'm currentlyworking on a VB.NET application to control Sketchup
(http://www.sketchup.com) using COM.

Sketchup has a color class with color.red, color.green and color.blue but
this is not appearing in the Interop layer. Instead, RGB colours are of
type System.Uint32.

I need a method to converty a UInt32 to RGB values. Can anyone point me in
the right direction?

TIA

Russ

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ColorTranslator

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Russ Green" <ma****@SPAMrussgreen.com> wrote in message
news:eW****************@TK2MSFTNGP15.phx.gbl...
I'm currentlyworking on a VB.NET application to control Sketchup
(http://www.sketchup.com) using COM.

Sketchup has a color class with color.red, color.green and color.blue but
this is not appearing in the Interop layer. Instead, RGB colours are of
type System.Uint32.

I need a method to converty a UInt32 to RGB values. Can anyone point me
in the right direction?

TIA

Russ

Nov 21 '05 #2

P: n/a
Right, but from UInt32?

This is my function but UInt32 cannot be converted to Integer which is what
is required for ColorTranslator.

Private Function GetPigment(ByRef oMaterial As Sketchup.Material) As
String
Dim oColor As Color = ColorTranslator.FromOle(CType(oMaterial.Color,
Integer))

Dim alpha As Double 'get the matertials opacity value
Dim r As Double = oColor.R / 255.0
Dim b As Double = oColor.B / 255.0
Dim g As Double = oColor.G / 255.0
Dim f As Double = (1.0 - alpha)
Dim t As Double = (1.0 - alpha)

GetPigment = "color rgbft <" & r & "," & b & "," & g & "," & f & ","
& t & ">"
End Function

Russ
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.