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 / getting pixel colour using point(x,y)

Author
Message
Code eater
18
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 19th Apr 2008 19:46
i need to look at the colour of a pixel on the screen very frequently... hopefully as frequently as every loop cant really be much less. but as you may know "point" is very slow.

any other way to do it? e.g. a dll that may be able to do it quicker someway.
i dont really know anything about the code behind dlls or anything so im not sure whether a dll could do it quicker.

codeeater
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 19th Apr 2008 22:08
You can do it a couple different ways. Probably the fastest would be using a custom dll. You could also probably use Windows GDI which is the main set of drawing functions for Windows (in the form of a DLL) but GDI is known to be slow - but it might be faster than DBC.

You can also use a memblock to capture areas of the screen (even single pixels if you like). I tried this method and I didn't get any real performance increase. I captured a pixel at a time, converted it to an image, then a memblock wherever the mouse pointer was and reported back the color from a memblock. This ran at about the same speed as POINT. Probably because of the constant conversions.

If your screen doesn't change then you can capture the whole screen once, convert it to a memblock and then report colors back based on position. That might be faster. I'll have to give that a try. But again, that method depens on your screen not changing.

Also, it depends on how you are using point. If you do it programitacally, one pixel at a time across the screen, it takes forever. But it seems to return a value pretty quickly if you report back the color under the mouse. You can see the fps stay pretty high with this example using the point command:



Enjoy your day.
Code eater
18
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 19th Apr 2008 23:00
Ok ill try Windows GDI... How? lol
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Apr 2008 01:51
what are you trying to do?

If you are drawing to screen you could have an array that stores the colour of each pixel (memblock faster).
If you want a colour picker from a gradient, use the same formula you used to draw the gradient.

It is far better to complete a 10 line program than to start a 10,000 line program.
Code eater
18
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 20th Apr 2008 19:17
Basicly Im looking on the screen to see what colour is behind a 3d object.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Apr 2008 21:43
Thought I'd put my money where my mouth is. Created a winapi function. Check it out here:

get_point()

Enjoy your day.
Code eater
18
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 21st Apr 2008 19:45 Edited at: 21st Apr 2008 20:20
wow! that should help it. ill test asap... thanks very much

[Edit]Wow! exactly what I need thanks so much!

cheers!

Login to post a reply

Server time is: 2026-07-05 16:04:54
Your offset time is: 2026-07-05 16:04:54