将屏幕截图(Bitblt)存储在内存缓冲区中以通过IdTCPClient进行发送 [英] Store a screen capture (Bitblt) in a memory buffer to send over IdTCPClient

查看:464
本文介绍了将屏幕截图(Bitblt)存储在内存缓冲区中以通过IdTCPClient进行发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Graphics :: TBitmap * bmpscreencapture = new Graphics :: TBitmap; 
bmpscreencapture-> Height = Screen->高度;
bmpscreencapture->宽度=屏幕 - >宽度;
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);
删除bmpscreencapture;

我目前有一段代码用于捕获屏幕并将屏幕截图显示到空白表单上。我想要做的是将捕获的图像存储到内存缓冲区中,然后使用indy客户端IdTCPClient通过互联网发送此缓冲区,以便通过类似程序使用indy服务器IDTCPServer接收。



有没有人有任何建议/想法如何做到这一点?我对图形编程相当陌生

解决方案使用TBitmap :: SaveToStream()方法将数据保存到TStream中,例如作为TMemoryStream。然后将TStream传递给Indy的TIdTCPConnection :: WriteStream()(Indy 9及更早版本)或TIdIOHandler :: Write(TStream)(Indy 10)方法。在接收端,然后可以使用TIdTCPConnection / TIdIOHandler :: ReadStream()方法将数据读入TStream,然后将TStream传递给TBitmap :: LoadFromStream()方法。


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

解决方案

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.

这篇关于将屏幕截图(Bitblt)存储在内存缓冲区中以通过IdTCPClient进行发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆