From Guillaume Taze, "This is a fix for the error popups which appeared when reading a corrupted file on windows. Errors are redirected to std::err instead."

Note from Robert Osfield, changed jpeg error report output from stderr to standard OSG notification system using OSG_WARN.
This commit is contained in:
Robert Osfield 2011-04-20 17:15:58 +00:00
parent 70aa087f6e
commit 63cfbadc95

View File

@ -429,6 +429,17 @@ my_error_exit (j_common_ptr cinfo)
longjmp(myerr->setjmp_buffer, 1);
}
static void
my_output_message (j_common_ptr cinfo)
{
char buffer[JMSG_LENGTH_MAX];
/* Create the message */
(*cinfo->err->format_message) (cinfo, buffer);
OSG_WARN<<buffer<<std::endl;
}
int
simage_jpeg_identify(const char *,
@ -494,6 +505,7 @@ int *numComponents_ret)
/* We set up the normal JPEG error routines, then override error_exit. */
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
jerr.pub.output_message = my_output_message;
/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp(jerr.setjmp_buffer))
{
@ -633,7 +645,10 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
int image_width = img.s();
int image_height = img.t();
if ( (image_width == 0) || (image_height == 0) )
{
OSG_DEBUG << "ReaderWriterJPEG::write_JPEG_file - Error no size" << std::endl;
return WriteResult::ERROR_IN_WRITING_FILE;
}
J_COLOR_SPACE image_color_space = JCS_RGB;
int image_components = 3;
@ -650,7 +665,11 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter
image_components = 3;
break;
}
default: return WriteResult::ERROR_IN_WRITING_FILE; break;
default:
{
OSG_DEBUG << "ReaderWriterJPEG::write_JPEG_file - Error pixel format non supported" << std::endl;
return WriteResult::ERROR_IN_WRITING_FILE; break;
}
}
JSAMPLE* image_buffer = (JSAMPLE*)(img.data());