Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / How to question: Converting RGB values back to the color value.

Author
Message
niteowl
17
Years of Service
User Offline
Joined: 13th Jul 2007
Location:
Posted: 11th Sep 2007 12:14
Hi, I'm a newbie and and so far have written quite a long program without asking for any programming answers, but I'm stuck on this one and yes, I've tried searching long & hard for a previous answer.
I need to convert RGB values back to the main color value. For example, the RGB values for white are 255,255,255...How do I convert this to the color value without drawing something and using the Point command ? (This would really slow down my main program loop).
I know that this value for white is 16777215.
By using...
color1 As Dword
r=255: g=255 : b=255
color1=rgb(r,g,b)
Print color1

I get...4294967295
On a calculator, i can divide that by 256 and get 16777215.99609375, but i can't get dbpro to do this division. Besides, this formula isn't as accurate with 255,255,0 (yellow) or 255,0,255 (pink).
I really need a simple formula to get the rgb values, which my program will have, back to the original color value, many times within my main loop.
Thanks to all who read & answer all these questions. This forum has already helped me a lot and the tutorials you guys put out are great.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Sep 2007 14:17
red = RGBR(MyColour)
green = RGBG(MyColour)
Blue = RGBB(MyColour)

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Sep 2007 14:26
My bad. Your way works, I'm just trying to find the neatest way. I think this would be it...

global dw = DWORD

...

dw = rgb(r,g,b)


niteowl
17
Years of Service
User Offline
Joined: 13th Jul 2007
Location:
Posted: 11th Sep 2007 21:13
WindowsKiller: Yes, your formula is exactly what i need.

THANK YOU, very much! Here, have a beer.

Login to post a reply

Server time is: 2024-11-25 13:52:04
Your offset time is: 2024-11-25 13:52:04