Screen capture

  • Thread starter Thread starter Mvmelle
  • Start date Start date
M

Mvmelle

Hello,

I want to capture the entire screen as a bitmap (so I can stream it as an
http GET).
But I fail to capture it.
I tried some samples I found on the internet, but without success.
Any help would be appreciated
 
Mvmelle said:
I want to capture the entire screen as a bitmap (so I can stream it as an
http GET).

This may help:

http://support.microsoft.com/?id=97193
But I fail to capture it.
I tried some samples I found on the internet, but without success.

Very nearly all of the WIN32 API's that can fail return an error code or set
the last error value in the calling thread. When you are having trouble it
is often a good idea to describe a little about the solutions you have tried
and how they have failed.

That said, though, the GDI group is probably better suited to your question
than this one.

Regards,
Will
 
Mvmelle said:
This, got me going.

That's good.
Now sending a HBITMAP trough an open socket is another problem.

Handles are by and large process-specific and therefore machine-specific as
well. You don't want to send the handle to a bitmap. You want to send the
bitmap's bits with an appropriate content (MIME) type, most often image/bmp.
If you need to conserve bandwidth at the expense of image quality then
image/jpeg may be a better choice. Of course then you'll need a compressor
as well.

Regards,
Will
 
save the bmp into IStream, then you can get HGLOBAL from the IStream. The
following is a clue

void savebmp(CBitmap& bmp)
{
CPictureHolder picture;
picture.CreateFromBitmap((HBITMAP)bmp, NULL, TRUE);
LPPICTUREDISP pPictureDisp=picture.GetPictureDispatch();
pPictureDisp->Release(); // must be released
IStorage* pStg = 0;

hr = ::StgCreateDocfile(L"c:\\picttest",
STGM_SHARE_EXCLUSIVE |
STGM_CREATE |
STGM_READWRITE,
0, &pStg);
if(SUCCEEDED(hr))
{
IStream* pStream = 0;

hr = pStg->CreateStream(L"PICTURE",
STGM_SHARE_EXCLUSIVE |
STGM_CREATE |
STGM_READWRITE,
0, 0, &pStream);
if(SUCCEEDED(hr))
{
hr = pPictureDisp->SaveAsFile(pStream,
TRUE, // save mem copy
NULL);
pStream->Release();
}
pStg->Release();
}
pPictureDisp->Release();
}
 
Back
Top