Board index » cppbuilder » How to handle "JPEG error #67"

How to handle "JPEG error #67"

Hi,
I wrote a program to show image(use TImage->Picture->Assign(jpg) to assign
one JPEG image) form one web camera. Sometimes, the program will prompt
"JPEG error #67".  I try to use
try {}
catch(...){}
 to catch this message, but the program still throwed this message out. How
can I catch this error message so that I can do some actions in this
situation? Can anyone help me.
Thanks

Mori.

 

Re:How to handle "JPEG error #67"


Quote
mori wrote:
> I wrote a program to show image(use TImage->Picture->Assign(jpg) to assign
> one JPEG image) form one web camera. Sometimes, the program will prompt
> "JPEG error #67".

What's the meaning of that error ? Which version of cbuilder ?

Could you show the complete code loading this image from file/stream ?

You could post two jpg's in the attachment newsgroup.
One ok and one that produces the error.

Hans.

Re:How to handle "JPEG error #67"


when you do your "catch" make sure you do not specify a particuler exception.
 just use a generic catch all type.
Quote
mori wrote:
> Hi,
> I wrote a program to show image(use TImage->Picture->Assign(jpg) to assign
> one JPEG image) form one web camera. Sometimes, the program will prompt
> "JPEG error #67".  I try to use
> try {}
> catch(...){}
>  to catch this message, but the program still throwed this message out. How
> can I catch this error message so that I can do some actions in this
> situation? Can anyone help me.
> Thanks

> Mori.

Re:How to handle "JPEG error #67"


P.S.
  also do this out side of the IDE..
Quote
mori wrote:
> Hi,
> I wrote a program to show image(use TImage->Picture->Assign(jpg) to assign
> one JPEG image) form one web camera. Sometimes, the program will prompt
> "JPEG error #67".  I try to use
> try {}
> catch(...){}
>  to catch this message, but the program still throwed this message out. How
> can I catch this error message so that I can do some actions in this
> situation? Can anyone help me.
> Thanks

> Mori.

Re:How to handle "JPEG error #67"


hi,
The following are my codes:
TImage *Image;
TJPEGImage        *jpg;
jpg = new TJPEGImage;
jpg->LoadFromStream(ms); // ms is the memory buffer stored my image from web
camera.
Image->Picture->Assign(jpg);   // run at this line will course error

I have found out the meaning of this error message. It's caused by the
incomplete image. (JPEG error #67 - Incomplete File)
My program will perform well regularly, but sometime(very low frequency) it
will prompt this error message. This program used UDP to retrieve image
data, and I know that's why my data will lose in data congestion. The
program always prompts this message when data lose, but I don't want user to
see this message box. How should I do to trap this error messgae?
Thanks.

"Hans Galema" <j.m.galema.dontuset...@maartens.nl> ???g??ls?D
:3eca3...@newsgroups.borland.com...

Quote
> mori wrote:

> > I wrote a program to show image(use TImage->Picture->Assign(jpg) to
assign
> > one JPEG image) form one web camera. Sometimes, the program will prompt
> > "JPEG error #67".

> What's the meaning of that error ? Which version of cbuilder ?

> Could you show the complete code loading this image from file/stream ?

> You could post two jpg's in the attachment newsgroup.
> One ok and one that produces the error.

> Hans.

Re:How to handle "JPEG error #67"


Quote
mori wrote:
> I have found out the meaning of this error message. It's caused by the
> incomplete image. (JPEG error #67 - Incomplete File)

If it is an incomplete image then don't call Image->Picture->Assign(jpg);

Try to find out why the image is incomplete. To few bytes ? A header error ?

Look at TJPEGImage Width and Height or at TStream Size.

You can still write the stream to files and post them in attachments.

Hans.

Re:How to handle "JPEG error #67"


Quote
mori wrote:
> The following are my codes:
> TImage *Image;
> TJPEGImage        *jpg;
> jpg = new TJPEGImage;
> jpg->LoadFromStream(ms); // ms is the memory buffer stored my image from web
> camera.

ms wil be a stream or a memorystream i think.

Quote
> Image->Picture->Assign(jpg);   // run at this line will course error

You said you used try - catch ???  Where ?

Are you sure the error comes from Image->Picture->Assign(jpg)
and not from jpg->LoadFromStream(ms); ?

Where is the 'delete jpg;' ?

How do you position the stream to 0 ?

Hans.

Re:How to handle "JPEG error #67"


Hi,
Sorry for poor information
The try and catch didn't trap the error message, so I removed it. The code
is as below

TImage *Image; // VCL component and declare in the mainform.h

void  ShowImage(TMemoryStream *ms)
{
    TJPEGImage        *jpg;
    jpg = new TJPEGImage;
    jpg->LoadFromStream(ms); // ms is the memory buffer stored my image from
web
    try{
                Image->Picture->Assign(jpg);
    }
    catch(...){}
    delete jpg;

Quote
}

I can't get the error image, because it happens in very low frequency,
Besides, the try and catch didn't work, so that I can't save this memory
buffer to a file.
I run the program in debuging mode and the program stop at "
Image->Picture->Assign(jpg);" so that I guess that executing this line will
cause the error message. Is it correct?

Thanks

"Hans Galema" <j.m.galema.dontuset...@maartens.nl> ???g??ls?D
:3ecb1...@newsgroups.borland.com...

Quote
> mori wrote:

> > The following are my codes:
> > TImage *Image;
> > TJPEGImage        *jpg;
> > jpg = new TJPEGImage;
> > jpg->LoadFromStream(ms); // ms is the memory buffer stored my image from
web
> > camera.

> ms wil be a stream or a memorystream i think.

> > Image->Picture->Assign(jpg);   // run at this line will course error

> You said you used try - catch ???  Where ?

> Are you sure the error comes from Image->Picture->Assign(jpg)
> and not from jpg->LoadFromStream(ms); ?

> Where is the 'delete jpg;' ?

> How do you position the stream to 0 ?

> Hans.

Re:How to handle "JPEG error #67"


Quote
mori wrote:
> I can't get the error image, because it happens in very low frequency,

Well if it was to high that would be a point. But to low ?

Of course you can. You can add somes lines that save every image to disk
from your TJPEGImage. You could even number all pictures with:

        static int times = 0;

        AnsiString FileName = "{*word*272}." + IntToStr ( ++times ) + ".jpg";

        jpg->SaveToFile ( FileName );

Quote
> Besides, the try and catch didn't work, so that I can't save this memory
> buffer to a file.

You can, as I showed above.

Quote
> I run the program in debuging mode and the program stop at "
> Image->Picture->Assign(jpg);" so that I guess that executing this line will
> cause the error message. Is it correct?

Don't know. Don't use the debugging mode. Go outside the IDE as well, to
try your program.

First, place a message in your catch statement. Wich excption do you handle ?
Second, place another try-catch around the jpg->LoadFromStream(ms); as well.

Third, make a testrun where you do NOT assign the ms to the
Image. (Outcomment Image->Picture->Assign(jpg); ). Then just let it run
to see if the error happens. (It will be in jpg->LoadFromStream(ms) then ;-)).

You did not react on another post to investigate Width, Heigth and
so on. Please try and react. If you don't try then please tell why
you did not take that effort.

Hans.

Other Threads