|
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.
|
|
|
|
|
I tried this:
void CMainDlg::CopyWndToClipboard(HWND pWnd )
{
CBitmap bitmap;
CClientDC dc(pWnd);
CDC memDC;
RECT rect;
memDC = ::CreateCompatibleDC(dc.m_hDC);
::GetWindowRect(pWnd,&rect);
bitmap.CreateCompatibleBitmap(dc.m_hDC, rect.right-rect.left,rect.top-rect.bottom );
CBitmap* pOldBitmap= (CBitmap*)(HBITMAP)::SelectObject(memDC,&bitmap);
::BitBlt(memDC,0, 0, rect.right-rect.left,rect.top-rect.bottom, dc.m_hDC, 0, 0, SRCCOPY);
::OpenClipboard(::GetParent(pWnd)) ;
EmptyClipboard() ;
SetClipboardData (CF_BITMAP, (HBITMAP)bitmap ) ;
CloseClipboard () ;
SelectObject(memDC,pOldBitmap);
bitmap.Detach();
}
But it doesn't work; all it does is throwing rubbish on the clipboard.
Any help is highly appreciated.
|
|
|
|
|
It definitely can be easily done as that method uses very little MFC and all of the MFC commands used in there directly map to standard windows API calls. Just look at their help and it wil tell you what the MFC does.
Maybe you should try not writing hybrid MFC/windows code in your example and rip out all of the MFC you still have in there. I.e. no CBitMap, ClientDC or CDC.
|
|
|
|
|
Hi. I have a problem that you may help me on:
I need to implement a hook that is triggered each time the screen is captured. More specifically, it must be activated BEFORE the screen capture is made.
Can you shed some light on this subject?
Thanks in advance!!!!!
|
|
|
|
|
I do not believe there is any such capability defined for Windows. You might consider trying to intercept the print-screen key with a keyboard hook, but that’s about the best I can suggest.
joe
|
|
|
|
|
Hello all
Once the screen is in a bitmap form, in the clipboard, how can I print it to my default printer?
Hope someone can help
Thanks
Alex
aevans@microknox.com.au
|
|
|
|
|
// Insert the following to capture the whole window
// as long as it fits on the screen
// display is of type CWnd* (or derived from)
CWnd * savedParent = display->GetParent();
CRect r;
display->GetWindowRect(&r);
WINDOWPLACEMENT wp;
display->GetWindowPlacement(&wp);
display->SetParent(NULL);
display->ModifyStyleEx(0, WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOMOVE);
// this might be a good place to force the with or height of the window bounds r
display->MoveWindow(10, 10, r.Width(), r.Height());
display->UpdateWindow();
/*
** PASTE THE CAPTURE CODE HERE
*/
// restore parent window
display->SetParent(savedParent);
// restore style without moving it
display->ModifyStyleEx( WS_EX_TOOLWINDOW | WS_EX_TOPMOST, 0,
SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOMOVE|WS_EX_TOOLWINDOW);
// restore window position
display->SetWindowPlacement(&wp);
-arne
|
|
|
|
|
|