+
+// JPEG error manager:
+
+struct wx_error_mgr : public jpeg_error_mgr
+{
+ jmp_buf setjmp_buffer; /* for return to caller */
+};
+
+/*
+ * Here's the routine that will replace the standard error_exit method:
+ */
+
+CPP_METHODDEF(void) wx_error_exit (j_common_ptr cinfo)
+{
+ /* cinfo->err really points to a wx_error_mgr struct, so coerce pointer */
+ wx_error_mgr * const jerr = (wx_error_mgr *) cinfo->err;
+
+ /* Always display the message. */
+ /* We could postpone this until after returning, if we chose. */
+ (*cinfo->err->output_message) (cinfo);
+
+ /* Return control to the setjmp point */
+ longjmp(jerr->setjmp_buffer, 1);
+}
+
+/*
+ * This will replace the standard output_message method when the user
+ * wants us to be silent (verbose==false). We must have such method instead of
+ * simply using NULL for cinfo->err->output_message because it's called
+ * unconditionally from within libjpeg when there's "garbage input".
+ */
+CPP_METHODDEF(void) wx_ignore_message (j_common_ptr WXUNUSED(cinfo))
+{
+}
+
+void wx_jpeg_io_src( j_decompress_ptr cinfo, wxInputStream& infile )