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 Professional Discussion / The POINT() function seems not to work properly...

Author
Message
Starshyne Emir
3
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 18th Mar 2020 20:18
How can I use the POINT() function to check properly the color of a point on screen (or on any bitmap?).
Do I need to lock pixels or do something else?
I know how to use RGBR(), RGBG() and RGBB() but always when I compare the colors I retrieve with the colors I stored inside variables when generating the original bitmap, they seem to be different and I can't use them to calculate collisions or terrain features as water or holes.

I'll try to exemplify here, since I deleted my test code. I will not detail how the bitmap is drawn to save time, but I'll try to make clear what I mean:

color1 = rgb(r1,g1,b1)
color2 = rgb(r2,g2,b2)
CREATE BITMAP n,w,h
(draw game level using color1 for ground and color2 for walls)
GET IMAGE n,w,h,1
DELETE BITMAP n
SPRITE n,0,0,n
SET SPRITE n,1,1
SIZE SPRITE n,SCREEN WIDTH(),SCREEN HEIGHT()
HIDE SPRITE

SYNC ON
SYNC RATE 60
DO
CLS
x and y are where I am in screen
PASTE SPRITE n,0,0
r = rgbr(POINT(x,y))
g = rgbg(POINT(x,y))
b = rgbb(POINT(x,y))
coloratposition = rgb(r,g,b)
IF coloratposition = color1 THEN do this
IF coloratposition = color2 THEN do that
SYNC
LOOP

Sometimes it works, sometimes it doesn't. Some colors match, some colors don't match. I get the image without filtering or scaling it to avoid distortions, so, I can't figure out what's going on.

God is real - except if declared as integer.
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 19th Mar 2020 04:19


That works just fine... well as find as DBP does on Windows 10 anyway.
I'd look over your code more closely to see what you're doing weirdly, but my friend is bugging me to play Fortnite.

Still I have a feeling the issue is with what you're trying to do.
Point( ) mind will always Default to the Currently Active Bitmap (if it's On-Screen or Off-Screen)... and do that, you can get the Bitmap Pointer; but the Pitch won't be available to automatically get... so I did add a comment to show how to calculate it (Safely)

Basically each Pixel is a 4 Byte Alignment, but as 32-bit is the Highest Format DBP supports; this should really only ever be 4 Bytes
Starshyne Emir
3
Years of Service
User Offline
Joined: 27th Nov 2016
Location: Porto Alegre, southern Brazil
Posted: 19th Mar 2020 16:57
Thanks for the feedbacki, pal.
I'll work on a code and if I find something working strangely, I'll share it in here.
God is real - except if declared as integer.

Login to post a reply

Server time is: 2020-03-30 15:06:29
Your offset time is: 2020-03-30 15:06:29