Article View: borland.public.cppbuilder.internet.socket
Article #4982Re: IdTCPServer & Image (Synchronize)
From: Remy Lebeau (TeamB)
Date: Mon, 08 Nov 2004 08:40
Date: Mon, 08 Nov 2004 08:40
77 lines
2854 bytes
2854 bytes
"Willie" <Willie.nospam@nospam.pchome.com.tw> wrote in message
news:418f1c70$1@newsgroups.borland.com...
> How can I update my Image?
<snip>
> How can I modify the code to work fine?
Try something like this code:
class TUpdateImage : public TIdSync
{
private:
TPicture* FPicture;
TJPEGImage* FJpg;
protected:
__fastcall TUpdateImage(TIdPeerThread* AThread, TStream* ASrcStream,
TPicture* ADestPicture);
void __fastcall DoSynchronize();
public:
__fastcall ~TUpdateImage();
static void __fastcall Update(TIdPeerThread* AThread, TPicture*
APicture);
};
__fastcall TUpdateImage::TUpdateImage(TIdPeerThread* AThread, TStream*
ASrcStream, TPicture* ADestPicture)
: TIdSync(AThread), FPicture(ADestPicture)
{
FJpg = new TJPEGImage;
FJpg->LoadFromStream(ASrcStream);
FJpg->CompressionQuality = 100;
}
__fastcall TUpdateImage::~TUpdateImage()
{
delete FJpg;
}
void __fastcall TUpdateImage::Update(TIdPeerThread* AThread, TPicture*
APicture);
{
TMemoryStream* TempStream = new TMemoryStream;
try
{
AThread->Connection->ReadStream(AStream, -1, false);
TempStream->Position = 0;
TUpdateImage* U = new TUpdateImage(AThread, TempStream,
APicture);
try {
U->Synchronize();
}
__finally {
delete U;
}
}
__finally {
delete TempStream;
}
}
void __fastcall TUpdateImage::DoSynchronize()
{
FPicture->Assign(FJpg);
}
void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
{
AnsiString szCommand = AThread->Connection->ReadLn();
if( szCommand=="UPDATE_IMAGE" )
TUpdateImage::Update(AThread, Image1->Picture);
}
Gambit
Technical Details
Message-ID:
<418f3099$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<418f1c70$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1e49695e4e7afe72 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <418f1c70$1@newsgroups.borland.com> Subject: Re: IdTCPServer & Image (Synchronize) Date: Mon, 8 Nov 2004 00:40:15 -0800 Lines: 79 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <418f3099$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1099903129 68.69.17.41 (8 Nov 2004 00:38:49 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail