473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

RGB from UINT32

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
2 3557
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Markebo | last post by:
I am taking the first steps letting python access a c-function in a ..dll-file, but need some help getting it right. WHat am I missing? --------------------------------- # Trying to access...
4
by: john smith | last post by:
I have never really understood the difference between the two notations below. I often run into code where they are passing in the address of some location. Some people do something like...
9
by: Xiangliang Meng | last post by:
Hi, all. I see a very strange fragment code today. Uint32 enum { a = 100; b = 200; }; NOTE: Uint32 is defined to be 'unsigned' in other source files.
1
by: Michel Racicot | last post by:
Hi there, The following code is troubling me: UInt32 nOffset = nStringEntriesOffset + (40 * nIndex); nStringEntriesOffset is a UInt32 containing 2124 nIndex is a UInt32 containing 5213 ...
2
by: Shankar | last post by:
Hi, I am writing a Managed C++ class library where interfaces take a unsigned int parameter. Looking at the CTS documentation, it is mentioned that there is no built- in type in VB.NET for this...
1
by: steellock | last post by:
The below code always get compile error, "Can not change Interger to UInt32". Then How to set the BackColor property With TextObjec .Name = "txtProductCode .SetText("Apple" .BackColor = 8 '...
2
by: steellock | last post by:
The below code always get compile error, "Can not change Integer to UInt32". Then how can I set BackColor property With txtob .Name = "txtProductCode .SetText("Apple" .BackColor = 8 '...
9
by: Chris Botha | last post by:
Hi, I have an UInt32 and want to stick the value into an Integer and get an Overflow exception, BUT using C# the same value can be casted into an int and the value is as expected. The Hex value is...
2
by: Bern McCarty | last post by:
In the old MEC++ syntax I can do this: // compile in VS 2005 shell with cl -clr:oldsyntax -LD ArrayCopyOldSyntax.cpp #using <mscorlib.dll> public __gc class CopyTest { private:...
11
by: Yaniv | last post by:
Hi How can I convert Uint32 variable to System.drawing.color ?? Thanks in advanced Yaniv
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.