< prev index next >

src/java.desktop/share/native/libjavajpeg/imageioJPEG.c

Print this page




2855         return data->abortFlag;  // We already threw an out of memory exception
2856     }
2857 
2858     // Allocate a 1-scanline buffer
2859     scanLinePtr = (JSAMPROW)malloc(scanLineSize);
2860     if (scanLinePtr == NULL) {
2861         freeArray(scale, numBands);
2862         JNU_ThrowByName( env,
2863                          "java/lang/OutOfMemoryError",
2864                          "Writing JPEG Stream");
2865         return data->abortFlag;
2866     }
2867     scanLineLimit = scanLinePtr + scanLineSize;
2868 
2869     /* Establish the setjmp return context for sun_jpeg_error_exit to use. */
2870     jerr = (sun_jpeg_error_ptr) cinfo->err;
2871 
2872     if (setjmp(jerr->setjmp_buffer)) {
2873         /* If we get here, the JPEG code has signaled an error
2874            while writing. */

2875         if (!(*env)->ExceptionOccurred(env)) {
2876             char buffer[JMSG_LENGTH_MAX];
2877             (*cinfo->err->format_message) ((j_common_ptr) cinfo,
2878                                           buffer);
2879             JNU_ThrowByName(env, "javax/imageio/IIOException", buffer);
2880         }
2881 
2882         freeArray(scale, numBands);
2883         free(scanLinePtr);
2884         return data->abortFlag;
2885     }
2886 
2887     // set up parameters
2888     cinfo->image_width = destWidth;
2889     cinfo->image_height = destHeight;
2890     cinfo->input_components = numBands;
2891     cinfo->in_color_space = inCs;
2892 
2893     jpeg_set_defaults(cinfo);
2894 




2855         return data->abortFlag;  // We already threw an out of memory exception
2856     }
2857 
2858     // Allocate a 1-scanline buffer
2859     scanLinePtr = (JSAMPROW)malloc(scanLineSize);
2860     if (scanLinePtr == NULL) {
2861         freeArray(scale, numBands);
2862         JNU_ThrowByName( env,
2863                          "java/lang/OutOfMemoryError",
2864                          "Writing JPEG Stream");
2865         return data->abortFlag;
2866     }
2867     scanLineLimit = scanLinePtr + scanLineSize;
2868 
2869     /* Establish the setjmp return context for sun_jpeg_error_exit to use. */
2870     jerr = (sun_jpeg_error_ptr) cinfo->err;
2871 
2872     if (setjmp(jerr->setjmp_buffer)) {
2873         /* If we get here, the JPEG code has signaled an error
2874            while writing. */
2875         RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
2876         if (!(*env)->ExceptionOccurred(env)) {
2877             char buffer[JMSG_LENGTH_MAX];
2878             (*cinfo->err->format_message) ((j_common_ptr) cinfo,
2879                                           buffer);
2880             JNU_ThrowByName(env, "javax/imageio/IIOException", buffer);
2881         }
2882 
2883         freeArray(scale, numBands);
2884         free(scanLinePtr);
2885         return data->abortFlag;
2886     }
2887 
2888     // set up parameters
2889     cinfo->image_width = destWidth;
2890     cinfo->image_height = destHeight;
2891     cinfo->input_components = numBands;
2892     cinfo->in_color_space = inCs;
2893 
2894     jpeg_set_defaults(cinfo);
2895 


< prev index next >