|
Sir,
Thaks for the article.Iam looking for such a code for some time.
Iam working on a projet for remote dektop viewing.Can you please explain how can I send the captured image through a socket.If you don't mind please give me the code.
-Biju
|
|
|
|
|
Might want to look into VNC... (Google for it!)
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
This is actually fairly difficult to do well. You would have to compress it, or you would be sending over two megabytes per screen at 1024x768, but even under the best of conditions this is going to give you abysmal performance.
JPEG compression would give you better compression, but it is lossy compression and the image would be distorted by the lossiness.
All you have to do is get the pixels from the bitmap and write them to the socket. Or write the compressed pixels. PKZIP-style (there are open-source ZIP libraries) compression would probably do better than run-length-encoding (RLE), so I'd suggest looking at that. GetBitmapBits will give you a pointer to the bitmap, after that you are pretty much on your own.
|
|
|
|
|
I can not give any code but i suggest U logic behide that...U have to do some effort on it..
Some of the steps are:
First collect Desktop HWND.
-Throught HWND value fill BITMAPINFO structure instance.
-Send this object to Another Terminal.
-Using that object display that image data to CDC object of targeted window.
Actually i have completed this project, i have not remembred what excat function i have used but i sugget U go throght BITMAPINFO structure and using MSDN sample U would be get code to fill the BItmapinfo structure..
Hope that U will Understood my suggetion/Ideia...
With Regards,
Jagdish
|
|
|
|
|
hello,
Sir,
firstly thanks for your great work related this artical
becoz this artical has help me very nuch!.
But still i have a Que -how can i get image into memory.
i mean to say that i want to transer current desktop image to
another Pc so how can collect current desktop image.I have alredy tried it by creating bitmap file(.bmp) and then sending
that file to another PC.But problem is that becoz of file r/w
there is too long delay so that at another end cant get current image.If anybody has idies or solN then help me.
|
|
|
|
|
It is not entirely clear what your question is about.
I've already shown how to capture a screen, and you claim you have already captured the desktop. So there is no question how to get an image into memory.
As far as sending it, you should compress it, using GIF, JPEG, or some other form of data compression of your choice. Zip might also work, although JPEG will probably give the best compression if a photo is on the screen. In any case, you can expect it will take a few seconds to transmit this image over a high-bandwidth communication channel, and vastly longer on dialup modems.
|
|
|
|
|
thanks for attention me.
Actualy i want to transfer image from one Pc to Another Pc.
if current desktop image is alrady in memory then how can i collect all the data ralated to that image.
I mean to say that if memDC object of CDC class contains data about image(using bitblt() fun of CDC).then how can i collect that image data to another memory location.Or How can i transfer that image to another socket(Pc) by using that memDC object.
I hope that you understood my problem.
thanking you,
Jagdish
|
|
|
|
|
There are several possible answers here.
First, if you are trying to do some sort of remote control, be aware that (a) this is very, very nontrivial and (b) it is not done by capturing screen images.
By "already in memory", I presume you mean that you have used the techniques I described to actually capture the screen.
If you have a memory DC with a bitmap, you can get the bitmap image using GetBitmapBits, GetDIBits, etc. You cannot transfer it to another PC by using a memDC; you have to extract the bits from the memory DC, then send them via a socket to another computer, which is running the other side of the communication, which transfers the bits into a memDC, and then displays it on another window.
Sending a bitmap for a 1024x178 display requires a minimum of 2,359,296 bytes for 24-bit color. But not all those bytes have to be transmitted. Using compression schemes such as JPEG, GIF, or even ZIP, you can sometimes compress that image down by a factor of 20:1 (on a good day, with luck). Thus, on a good day you might only need 120K bytes. Your Mileage May Vary.
The time taken to do the transmission is, of course, a function of the network bandwidth. But don't think 100Base-T (100Mb/s) can actually transfer 100Mb/s. Concepts such as packetization mean that you will get a certain overhead every, well, 1456 bytes. You might need 85-100 packets to transmit a compressed image; five or ten times that for one that does not compress well. Add to this the transmission overhead, packet flow control, etc. and you will be lucky to get anything vaguely useful. Figure your best will be 1Mb, your worst, 18Mb. So the worst case would take, if 100% of the bandwidth could be used, about 188ms per screen. But realistically, you might expect to get one or two screens per second under worst case, over 100Base-T. For 10Base-T, that's one screen every 5 to 10 seconds. By the time you get to 1000Base-T (gigabit copper) you would hope to see 20ms/screen, but I doubt you can get that rate (that's 50 frames/sec, and I know that doesn't happen over 1000Base-T without a LOT of effort).
Dialup is ruled out entirely.
|
|
|
|
|
thanks for reply me.
but sir,Actualy i dont know to much about GetDibBits function.how i can use it and how i can set DIB bits at other end.if possible then plz give me some code that will be help me........
Waiting for reply....
Regards,
Jagdish
|
|
|
|
|
As to how to use it, you have to read the documentation, same as I do. I use it about once every two years, and whenver I need to use it, I just read the documentation. Same for SetDIBits.
joe
|
|
|
|
|
Hi,
Does anyone have some resource or example about capture mouse pointer ?
Thanks
Rodrigo
|
|
|
|
|
It is tricky. I basically do a GetCursor, then get the cursor bitmap, and then get the mouse position, compute it relative to the window I've just snapped, then do a DrawIcon. Something like that, at least. I've misplaced the code, and with 750K files on my system, I can't easily find it.
|
|
|
|
|
I've tried to get the mouse pointer with GetCursor and DrawIcon withou obtain success, i'm using hooks to get mouse events and it receive a POINT struct that's contain the x and y cordenates but i can't draw in the DC object , the cursor doesn't appears in the image.
Thanks for your help
Rodrigo
|
|
|
|
|
I'm currently in get-the-code-out-last-week mode (fortunately the hardware is a week late for beta as well...) so don't have time to look for the code that did this. Poke me again in about a week, when I'm out from under this current mess. Sorry for the delay, but I'm coding 18 hours a day right now.
|
|
|
|
|
Ok Joseph , thanks a lot and i will search more about it
If you can send me some codes later i will be thankful
Thanks and congratulations for you article
|
|
|
|
|
Hi,
Nice article !!
I was looking at approaches for finding the screen position [ x, y ] for the object in the clipboard. So, if there is an text object(say through selection from a notepad) that was copied to the clipboard, I would like to determine its absolute position w.r.t to the window screen[ global co-ordinates ].
Is this even possible ? Can you help me out with some approaches to attack this problem ?
Thanks.
Andy
|
|
|
|
|
This is nearly impossible. You can't tell from the clipboard what application put something into it, and therefore you can't tell what program was involved. In addition, except in the very restricted cases of NotePad and WordPad which are just wrappers around an EDIT and RICHEDIT control, respectively, there is no general way to even ask an application what its selection is, let alone where it is.
|
|
|
|
|
capture screen use DC is easy, but I can't catpure a DirectX or OpenGL window. please tell me about it, thanks!
xudb@necas.nec.com.cn
|
|
|
|
|
I have no idea. None whatsoever.
|
|
|
|
|
If you application uses DirectX, you need to use DirectX commands to capture the screen. Little code, and if you google, you will a few examples.
Note, you may have problems capturing from another DirectX application. Usually it locks the DirectX display for its own use and it wont let another process access the contents.
|
|
|
|
|
if anybody know please tell me.Thank you
toon
|
|
|
|
|
Read about bitmap headers. Take the bitmap bits, write a header on the front, and write the bits out.
|
|
|
|
|
If Possible Can you let me know how to code it
because I have no idea how to implement it
Thank you
toon
|
|
|
|
|
I believe there are examples here on codeproject for how to do this. For example, I was able to quickly find one article
http://www.codeproject.com/bitmap/cximage.asp
which appears that it would contain all the code you need. I found this by searching for "bitmap save file"
|
|
|
|
|
Two options if you want to do it programmatically.
Look into CxImage, which is a free graphics library. With it you can easily do this, as it is set up to convert between various formats.
If you need something more lightweight, google into the PNG library a little. They have one example code snippet that shows how to take an image from the clipboard and save it as a compressed PNG file. I use it and it works just beautifully and the PNG code is free as well.
|
|
|
|