views:

566

answers:

2

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  A: 

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.

Remy Lebeau - TeamB
A: 

good question and great for answer too. It helped me. But if the file lets say is an screenshot(BitBlt), how to compress it? cuz seems send forever been just on LAN.

passingthru
Indy has a Compression component that you can attach to each end of the connection.
Remy Lebeau - TeamB