quick question about getting pixels

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
deanh22a
Posts: 23
Joined: Thu Feb 08, 2007 11:08 pm

quick question about getting pixels

Post by deanh22a »

Is there a way to get a pixel from outside the program window, such as from the desktop or another running application?
NicholasMag
Posts: 45
Joined: Fri Mar 09, 2007 8:06 pm

Post by NicholasMag »

Like a screenshot? Is that what your meaning? If so, i beleive there is a way, havnt really checked into it yet.

But if you mean grabbing colors and sections off the desktop to view inside of irrlicht, i would suppose you need some kind of recorder to show whats going on behind the irrlicht screen. But ive never heard of anything like that.

Please explain with a little more detail on what you want to do. And i will try my best to see what i can do for you.
deanh22a
Posts: 23
Joined: Thu Feb 08, 2007 11:08 pm

Post by deanh22a »

I know there's dx code you can use to capture images from the screen, not just within one window, but what's showing on the entire screen. I don't really need to do that so much as capture a single pixel. For example if i'm making a simple security program to see if someone messes with an icon on my desktop, my program can be running in the background to test if an icon has been moved or clicked on. If so, then I can have my program excecute whatever i need done.
NicholasMag
Posts: 45
Joined: Fri Mar 09, 2007 8:06 pm

Post by NicholasMag »

so you want some sort of background service to monitor your PC right?

What exactly do you want it to monitor? Because from the sounds of it Irrlicht isnt the way to go for this.

Explain exactly what you are wanting to try and accomplish. Because there are a wide variety of things it could be you want done, Would help lots more if we knew what you want done.

You dont have to go in complete detail, just the basics of what you want done.

From the sounds of it, you want to grab a color off the desktop, because you are reffering to a pixle. Am i right?
deanh22a
Posts: 23
Joined: Thu Feb 08, 2007 11:08 pm

Post by deanh22a »

That was just an example. All I'm trying to do right now is grab the color of a pixel from the screen, given that pixel's absolute on-screen coordinates. Thats all I want to know.
NicholasMag
Posts: 45
Joined: Fri Mar 09, 2007 8:06 pm

Post by NicholasMag »

hrm, the only way i would see anyone doing this is finding an open source project that grabs a pixle, and implement it with irrlicht, because as far as i know Irrlicht doesnt support it.

Will do some research though, im sure it can be done.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

What OS are you using?
in windows, you can get ti by doing this(Not sure it compiles right and is 100% perfect...)

Code: Select all

HDC DeskDC;

//I think both of these produces the same result.
//The cursor will not be 'getpixeled' though.
//Anyway, dont use both at the same time, if so you'll grab 2 and drop 1 ;)
DeskDC=GetDC(NULL);
DeskDC=CreateDC("DISPLAY",NULL,NULL,NULL);

u32 PixColor=GetPixel(DeskDC, 50,50);

ReleaseDC(NULL, DeskDC);
If you don't have anything nice to say, don't say anything at all.
deanh22a
Posts: 23
Joined: Thu Feb 08, 2007 11:08 pm

Post by deanh22a »

Luben wrote:What OS are you using?
in windows, you can get ti by doing this(Not sure it compiles right and is 100% perfect...)

Code: Select all

HDC DeskDC;

//I think both of these produces the same result.
//The cursor will not be 'getpixeled' though.
//Anyway, dont use both at the same time, if so you'll grab 2 and drop 1 ;)
DeskDC=GetDC(NULL);
DeskDC=CreateDC("DISPLAY",NULL,NULL,NULL);

u32 PixColor=GetPixel(DeskDC, 50,50);

ReleaseDC(NULL, DeskDC);
thanks.

I'm using visual studio 2005 c++ with windows xp. That code works for windows ce or later. My compiler doesnt recognize the HDC identifier.


NicholasMag wrote:hrm, the only way i would see anyone doing this is finding an open source project that grabs a pixle, and implement it with irrlicht, because as far as i know Irrlicht doesnt support it.

Will do some research though, im sure it can be done.
I figured irrlicht probably didnt have its own functions for this, but i thought i'd ask. If anything, i was hoping there was a quick and easy way to do it that someone would be familiar with. I guess if not, i can just use the dx stuff to capture a part of the screen and check the desired pixel from there.
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

deanh22a wrote:My compiler doesnt recognize the HDC identifier.
If your compiler doesn't recognize HDC, rememer to #include <windows.h>.
If you don't have anything nice to say, don't say anything at all.
deanh22a
Posts: 23
Joined: Thu Feb 08, 2007 11:08 pm

Post by deanh22a »

Thanks. It works now. :)
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

damn, whole thing looked difficult but solution is so easy that im amazed :o
Post Reply