< prev index next >

src/java.desktop/share/native/libsplashscreen/splashscreen_jpeg.c

Print this page




 220 typedef struct my_error_mgr *my_error_ptr;
 221 
 222 static void
 223 my_error_exit(j_common_ptr cinfo)
 224 {
 225     /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
 226     my_error_ptr myerr = (my_error_ptr) cinfo->err;
 227 
 228     /* Always display the message. */
 229     /* We could postpone this until after returning, if we chose. */
 230     (*cinfo->err->output_message) (cinfo);
 231 
 232     /* Return control to the setjmp point */
 233     longjmp(myerr->setjmp_buffer, 1);
 234 }
 235 
 236 int
 237 SplashDecodeJpegStream(Splash * splash, SplashStream * stream)
 238 {
 239     struct jpeg_decompress_struct cinfo;
 240     int success = 0;
 241     struct my_error_mgr jerr;
 242 
 243     cinfo.err = jpeg_std_error(&jerr.pub);
 244     jerr.pub.error_exit = my_error_exit;
 245 
 246     if (setjmp(jerr.setjmp_buffer)) {

 247         goto done;
 248     }
 249     jpeg_create_decompress(&cinfo);
 250     set_stream_src(&cinfo, stream);
 251     success = SplashDecodeJpeg(splash, &cinfo);
 252 
 253   done:
 254     jpeg_destroy_decompress(&cinfo);
 255     return success;
 256 }


 220 typedef struct my_error_mgr *my_error_ptr;
 221 
 222 static void
 223 my_error_exit(j_common_ptr cinfo)
 224 {
 225     /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
 226     my_error_ptr myerr = (my_error_ptr) cinfo->err;
 227 
 228     /* Always display the message. */
 229     /* We could postpone this until after returning, if we chose. */
 230     (*cinfo->err->output_message) (cinfo);
 231 
 232     /* Return control to the setjmp point */
 233     longjmp(myerr->setjmp_buffer, 1);
 234 }
 235 
 236 int
 237 SplashDecodeJpegStream(Splash * splash, SplashStream * stream)
 238 {
 239     struct jpeg_decompress_struct cinfo;
 240     int success;
 241     struct my_error_mgr jerr;
 242 
 243     cinfo.err = jpeg_std_error(&jerr.pub);
 244     jerr.pub.error_exit = my_error_exit;
 245 
 246     if (setjmp(jerr.setjmp_buffer)) {
 247         success = 0;
 248         goto done;
 249     }
 250     jpeg_create_decompress(&cinfo);
 251     set_stream_src(&cinfo, stream);
 252     success = SplashDecodeJpeg(splash, &cinfo);
 253 
 254   done:
 255     jpeg_destroy_decompress(&cinfo);
 256     return success;
 257 }
< prev index next >