Boost logo

Boost Users :

Subject: [Boost-users] Standard error handler in gil jpeg_io extension calls exit()
From: Peter Goetz (peter.gtz_at_[hidden])
Date: 2010-01-31 11:28:14


Hi,

I'm using the gil jpeg_io extension like this:

gil::rgb8_image_t img;
gil::jpeg_read_image("test.jpg",img);

As it turned out, if "test.jpg" is not a jpeg the program will quit
with the message:

"Not a JPEG file: starts with 0x6b 0x6a"

although I put a try-catch-block around it.

Digging a bit deeper, I found, that this is because in
boost/gil/extension/io/jpeg_io_private.hpp the jpeg_reader::init()
function uses the standard error handler:

_cinfo.err=jpeg_std_error(&_jerr);

which calls the exit() function. I'd prefer to have an exception and
handle the exception in my main program rather than in the library.

Is there a way to do that? To me it seems there's no other way than
modifying the jpeg_io_extension. Or am I missing something?

Any help is very appreciated!
Peter


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net