Store a screen capture (Bitblt) in a memory buffer to send over IdTCPClient

让人想犯罪 __ 提交于 2019-12-10 12:17:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!