RGB from UINT32

  • Thread starter Thread starter Russ Green
  • Start date Start date
R

Russ Green

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top