ichen
asked on
how to send a *.bmp picture over tcp/ip
i want to send a *.bmp picture over ip.
1. i think the best is to save the picture to a TStream variable.
But how to do that?
2. if i can do that (number one). how should i send the picture to the clients? should i use sendbuf?
3. if i can do number two, how can the client receive the picture. should he/she use the receivebuf? if yes, how to convert it to TStream?
Full source codes in Delphi 4.0 is very appreciated.
1. i think the best is to save the picture to a TStream variable.
But how to do that?
2. if i can do that (number one). how should i send the picture to the clients? should i use sendbuf?
3. if i can do number two, how can the client receive the picture. should he/she use the receivebuf? if yes, how to convert it to TStream?
Full source codes in Delphi 4.0 is very appreciated.
I can e-mail you a bare bone example how to send a buffer using the Delphi tcp-ip components.
Epsylon.
Epsylon.
Epsylon
Please Mail it to me
hamidhossain@hotmail.com
Please Mail it to me
hamidhossain@hotmail.com
ASKER
can anyone put all the sources given by madshi into one procedure?
i mean, for examples when i click the "send" button, inside the onclick, it creates a buffer to store the bitmap and then send it through the server's sendbuf.
and the client's onclick handles the receipt and also the showing of the image.
i mean, for examples when i click the "send" button, inside the onclick, it creates a buffer to store the bitmap and then send it through the server's sendbuf.
and the client's onclick handles the receipt and also the showing of the image.
Sorry, but it is not possible to put everything in a single procedure because you need some eventhandlers.
ASKER
yes, epsilon, but what i mean is whether someone can put the codes for buffering the pict and perhaps the sound in the sned's "onclick" eventhandler, while inside it it calls other eventhandlers. it also applies to the client's "onread" it changes the buffer into bitmap [and also plays the sound]. thank you.
if you can reply it immediately in 24 hours, i will likely increase the points :) -- to anyone
if you can reply it immediately in 24 hours, i will likely increase the points :) -- to anyone
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know you got this source from Mastering Delphi :) I already try this program and it's work in the LAN but if i try it in internet .. it doesn't work properly..
procedure BitmapToBuffer(bmp: TBitmap; var buffer: pointer; var size: integer);
var ms : TMemoryStream;
begin
ms := TMemoryStream.Create;
try
bmp.SaveToStream(ms);
size := ms.size;
GetMem(buffer, size);
Move(ms.memory^, buffer^, size);
finally ms.Free end;
end;
Don't forget to free the buffer with FreeMem(buffer) after you've sent it!
procedure BufferToBitmap(buffer: pointer; size: integer) : TBitmap;
var ms : TMemoryStream;
begin
result := TBitmap.Create;
ms := TMemoryStream.Create;
try
ms.size := size;
Move(buffer^, ms.memory^, size);
result.ReadFromStream(ms);
finally ms.Free end;
end;
About the network stuff: Look at this page:
http://www.rtfm.be/fpiette/indexuk.htm
There you'll find very good (and free) components with sources and some demos.
Does this help?
Regards, Madshi.