问题
In c++ builder 6 on windows vista ...
Graphics:: TBitmap * bmpscreencapture = new Graphics::TBitmap;
bmpscreencapture-> Height = Screen-> Height;
bmpscreencapture-> Width = Screen-> Width;
HDC ScreenSrc = GetWindowDC (0);
BitBlt (bmpscreencapture-> Canvas-> Handle, 0, 0, Screen-> Width,
Screen-> Height, ScreenSrc, 0, 0, SRCCOPY);
Canvas->Draw(10, 10, bmpscreencapture);
ReleaseDC (GetDesktopWindow (), ScreenSrc);
delete bmpscreencapture;
I currently have a section of code for capturing the screen and displaying the screen capture onto an empty form. What I would like to do is store the captured image into a memory buffer and then send this buffer over the internet using the indy client IdTCPClient to be received by a similar program using indy server IDTCPServer.
Has anyone got any suggestions/ideas of how to accomplish this?? I am fairly new to graphics programming
回答1:
Use the TBitmap::SaveToStream() method to save the data to a TStream, such as a TMemoryStream. Then pass the TStream to Indy's TIdTCPConnection::WriteStream() (Indy 9 and earlier) or TIdIOHandler::Write(TStream) (Indy 10) method. On the recieving end, you can then use the TIdTCPConnection/TIdIOHandler::ReadStream() method to read the data into a TStream, and then pass the TStream to the TBitmap::LoadFromStream() method.
来源:https://stackoverflow.com/questions/1256605/store-a-screen-capture-bitblt-in-a-memory-buffer-to-send-over-idtcpclient