By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,127 Members | 939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,127 IT Pros & Developers. It's quick & easy.

where is the desktop image stored && how can i read it

P: 30
hy

i want to write a program that can determin the code ( the 32 bit diget ) of a specific pixel on the desktop.
can i somehow get the memory adress of the desktop image or is there a predifined function that can return the code of a specific pixel ( ex: meaby somting like "int get_pixel(int x, int y) " ) ?

i'm usin win xp pro sp2 and visual c++ 2005
Dec 24 '06 #1
Share this Question
Share on Google+
3 Replies


100+
P: 145
This may not be the most efficient way to do it, but I did write some win32 extensions for my EasyBMP C++ bitmap library.

The included code sample does a screen capture to a BMP bitmap image. (You can examine the source to determine how it works.) If you want to capture only the desktop, you'd have to find the win32 command to minimize all windows. (This and
this may get you started.)

Suppose then that you have captured the screen to a BMP object ScreenCap. Then you'd get the (i,j) pixel as follows:

Expand|Select|Wrap|Line Numbers
  1. cout << "pixel (i,j) is (" << (int) Image(i,j)->Red << "," 
  2.      << (int) Image(i,j)->Green << ","
  3.      << (int) Image(i,j)->Blue << ","
  4.      << (int) Image(i,j)->Alpha << ")" << endl;
  5.  
You can combine these red, green, blue, and alpha values as you see fit. For instance, to put them into a 32-bit number, I guess you might do this:
Expand|Select|Wrap|Line Numbers
  1. int AllTogether = 255*255*255*Image(i,j)->Blue
  2.                 + 255*255*Image(i,j)->Green
  3.                 + 255*Image(i,j)->Red
  4.                 + Image(i,j)->Alpha;
  5.  
(Note that the RGBQUAD data type in win32 stores in order of blue, green, red, alpha). Now, I may have my data reversed, in which case you'd want to reverse my code sample to alpha, red, green, blue.

I hope this gets you started. -- Paul
Dec 24 '06 #2

P: 30
thanks

you have just oppend a new part of programing to me ( i never tried to work with pictures of any kind)

but you were wright " this isen't the best way" to do what i want in my program.
maby i didn't discribed whit inaf detalies so :

my program shold retrive a pixel (it doesent mather in what format it stores it) from desktop and sed it to another program over the internet and the program at the other end (runnig in fool screen ) should be able to show it at the same position it was on the first desktop.
Dec 24 '06 #3

100+
P: 145
thanks

you have just oppend a new part of programing to me ( i never tried to work with pictures of any kind)

but you were wright " this isen't the best way" to do what i want in my program.
maby i didn't discribed whit inaf detalies so :

my program shold retrive a pixel (it doesent mather in what format it stores it) from desktop and sed it to another program over the internet and the program at the other end (runnig in fool screen ) should be able to show it at the same position it was on the first desktop.
Ah, that sounds like a remote desktop / virtual network client type of application. You'd have to start looking at TCP/IP after that.

You might consider looking at TightVNC. It's a very good app, and if it's something you're still interested in doing yourself, you could look at their code, as it's GPL. -- Paul

*edit*
Another way to do this would be to take screencaps at regular intervals and use a command-prompt type of emailer (e.g., sendmail) to email the screencaps wherever they need to go, or upload them to an http server. So, you could have somethign like http://some.site.com/remote.bmp that gets updated every minute by ftp or sftp upload based upon your software. WinSCP has the option to keep a remote director synced, so that would work just fine.
*/edit*
Dec 24 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.