🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #5684

Re: Send a jpeg

#5684
From: Fabi�n
Date: Tue, 06 Jul 2004 14:07
85 lines
3155 bytes
I send the file in parts.  Then I join them again. But i doesn't work.  I
think I did it too simple

here is my code:

BYTE tBuffer[100];
TJPEGImage *tjp = new TJPEGImage();
TMemoryStream* tpms = new TMemoryStream();
//--------------------------------------------------------------------------
-
void __fastcall TfMain::wmImagenClick(TObject *Sender)
{
    BYTE Buffer[100];
    int pos = 0;

    OpenPictureDialog->FileName = GraphicFileMask(__classid(TJPEGImage));

    if (OpenPictureDialog->Execute())
    {
        TJPEGImage *jp = new TJPEGImage();
        TMemoryStream* pms = new TMemoryStream();

        jp->LoadFromFile(OpenPictureDialog->FileName);
        jp->SaveToStream(pms);

        while(pos < pms->Size - 100)
        {
            pms->Seek(pos, soFromBeginning);
            pms->ReadBuffer(Buffer, 100);

            ClientSocket->Socket->SendBuf(Buffer, 100);

            pos += 100;
        }

        pms->Seek(pos, soFromBeginning);
        pms->ReadBuffer(Buffer, pms->Size - pos);
        ClientSocket->Socket->SendBuf(Buffer, pms->Size - pos);
    }
}
//--------------------------------------------------------------------------
-
void __fastcall TfMain::ServerSocketClientRead(TObject *Sender,
      TCustomWinSocket *Socket)
{
    int total = Socket->ReceiveLength(), recived, newpacketsize;

    recived = tpms->Size;

    if(total - recived > 100)
        newpacketsize = 100;
    else
        newpacketsize = total - recived;

    Socket->ReceiveBuf(tBuffer, newpacketsize);

    tpms->WriteBuffer(tBuffer, newpacketsize);

    if(tpms->Size == total)
    {
        tjp->LoadFromStream(tpms);

        PaintBox->Canvas->Draw(0,0,tjp);
    }
}
//--------------------------------------------------------------------------
-


"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> escribi� en el
mensaje news:40e99afa$1@newsgroups.borland.com...
>
> "Fabi�n" <fabianfierro@hotmail.com> wrote in message
> news:40e99192$1@newsgroups.borland.com...
>
> > I'm trying to transfer a jpeg.
> > I have problems using a stream.
>
> Can you be more specific please?  What exactly are you having a problem
> with?
>
>
> Gambit
>
>
Technical Details
Message-ID: <40eab37b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40e99192$1@newsgroups.borland.com> <40e99afa$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,bae0299eb0ad2238
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII
Reply-To: "Fabi�n" <fabianfierro@hotmail.com>
From: "Fabi�n" <fabianfierro@hotmail.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <40e99192$1@newsgroups.borland.com> <40e99afa$1@newsgroups.borland.com>
Subject: Re: Send a jpeg
Date: Tue, 6 Jul 2004 11:07:08 -0300
Lines: 87
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: 200.68.64.9
Message-ID: <40eab37b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1089123195 200.68.64.9 (6 Jul 2004 07:13:15 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail