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.

DarkBASIC Discussion / extracting color data using point command

Author
Message
Pixelator
17
Years of Service
User Offline
Joined: 8th Jul 2007
Location: here
Posted: 20th Dec 2007 23:11
Hi, i am working on a program, and in a function i need to extract the amount of red in a pixel. I know tha it involves the point() command but since it give the raw number, i am lost how to extract only the red value and put it in a variable.


Maryville Game Developers
Visit our website at http://www.freewebs.com/maryville-game-developers/index.htm
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Dec 2007 00:08 Edited at: 21st Dec 2007 00:11
rgbr(n#)
returns the amount of red in a colour integer.
also available in rgbg() and rgbb()

or you could divide it by 65536

Tip: Point works much faster with off-screen bitmaps

I'm winking a lot lol

demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 21st Dec 2007 00:12 Edited at: 21st Dec 2007 00:15
Hmm. I think that point reads back a value in which it comes out as something like (r*256^2)+(g*256)+b
therefore logically if you divide the point value by 256^2 which is (whips out an emergency calculator) 65536, then the integer it leaves should be the red value.
Here you go:

that might even work.
if you're lucky.
Just made it up on the spot though and I've never tried it yet so... there's a reasonable chance it won't...



EDIT:
Oh Obese. Hate you. Spent so long thinking up a simple example of how to do it that you'd posted. Also, I didn't know about that rgbr command...

"A West Texas girl, just like me"
-Bush
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Dec 2007 00:38
@DB
The only reason I know it's 65536 is because I didn't know about the rgbr command

I expanded on your code a bit.


Pixelator
17
Years of Service
User Offline
Joined: 8th Jul 2007
Location: here
Posted: 21st Dec 2007 02:16
@obese

oops! Missed that in help commands. Thankyou


Maryville Game Developers
Visit our website at http://www.freewebs.com/maryville-game-developers/index.htm

Login to post a reply

Server time is: 2025-06-02 09:56:52
Your offset time is: 2025-06-02 09:56:52