We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Another question bugs me
Page Index Toggle Pages: 1
Another question bugs me (Read 581 times)
Another question bugs me
Aug 13th, 2009, 6:41pm
 
I'm using loadImage("URL") to retrieve pictures from a webcam. So far everything is fine. The pictures come flowing in. But every now and then, one of the images seems to be corrupted.
In these cases i get an orange error alert in the console-area of the sketch window saying:
Corrupt JPEG data: bad Huffman code
or
Premature end of JPEG file

And that's it.
The PImage is not null and has width != -1. I can loadPixels() and pixels.length is the full value as the good pictures.
But the image is broken!
It contains only a few lines of content and then zero.

What can i do to catch this error?
Re: Another question bugs me
Reply #1 - Aug 17th, 2009, 10:34pm
 
You may be able to surround the loadImage() call with a try/catch block.
Look up the exact error to catch, or just assume that the bad Huffman code was found.
Code:
try {
 loadImage("source.jpg");
} catch(Exception er) {
 //something bad happened
 er.printStackTrace(); //I would expect this to print out the same error
}
Page Index Toggle Pages: 1