527 private void skipImage() throws IOException {
528 if (debug) {
529 System.out.println("skipImage called");
530 }
531 boolean foundFF = false;
532 for (int byteval = iis.read();
533 byteval != -1;
534 byteval = iis.read()) {
535
536 if (foundFF == true) {
537 if (byteval == JPEG.EOI) {
538 return;
539 }
540 }
541 foundFF = (byteval == 0xff) ? true : false;
542 }
543 throw new IndexOutOfBoundsException();
544 }
545
546 /**
547 * Returns <code>true</code> if there is an image beyond
548 * the current stream position. Does not disturb the
549 * stream position.
550 */
551 private boolean hasNextImage() throws IOException {
552 if (debug) {
553 System.out.print("hasNextImage called; returning ");
554 }
555 iis.mark();
556 boolean foundFF = false;
557 for (int byteval = iis.read();
558 byteval != -1;
559 byteval = iis.read()) {
560
561 if (foundFF == true) {
562 if (byteval == JPEG.SOI) {
563 iis.reset();
564 if (debug) {
565 System.out.println("true");
566 }
567 return true;
597
598 /**
599 * Reads header information for the given image, if possible.
600 */
601 private void readHeader(int imageIndex, boolean reset)
602 throws IOException {
603 gotoImage(imageIndex);
604 readNativeHeader(reset); // Ignore return
605 currentImage = imageIndex;
606 }
607
608 private boolean readNativeHeader(boolean reset) throws IOException {
609 boolean retval = false;
610 retval = readImageHeader(structPointer, haveSeeked, reset);
611 haveSeeked = false;
612 return retval;
613 }
614
615 /**
616 * Read in the header information starting from the current
617 * stream position, returning <code>true</code> if the
618 * header was a tables-only image. After this call, the
619 * native IJG decompression struct will contain the image
620 * information required by most query calls below
621 * (e.g. getWidth, getHeight, etc.), if the header was not
622 * a tables-only image.
623 * If reset is <code>true</code>, the state of the IJG
624 * object is reset so that it can read a header again.
625 * This happens automatically if the header was a tables-only
626 * image.
627 */
628 private native boolean readImageHeader(long structPointer,
629 boolean clearBuffer,
630 boolean reset)
631 throws IOException;
632
633 /*
634 * Called by the native code whenever an image header has been
635 * read. Whether we read metadata or not, we always need this
636 * information, so it is passed back independently of
637 * metadata, which may never be read.
638 */
639 private void setImageData(int width,
640 int height,
641 int colorSpaceCode,
642 int outColorSpaceCode,
643 int numComponents,
850
851 }
852
853 list.add(getImageType(JPEG.JCS_GRAYSCALE));
854 list.add(getImageType(JPEG.JCS_YCC));
855 break;
856 case JPEG.JCS_YCbCrA: // Default is to convert to RGBA
857 // As there is no YCbCr ColorSpace, we can't support
858 // the raw type.
859 list.add(getImageType(JPEG.JCS_RGBA));
860 break;
861 }
862
863 return new ImageTypeIterator(list.iterator());
864 }
865
866 /**
867 * Checks the implied color conversion between the stream and
868 * the target image, altering the IJG output color space if necessary.
869 * If a java color conversion is required, then this sets up
870 * <code>convert</code>.
871 * If bands are being rearranged at all (either source or destination
872 * bands are specified in the param), then the default color
873 * conversions are assumed to be correct.
874 * Throws an IIOException if there is no conversion available.
875 */
876 private void checkColorConversion(BufferedImage image,
877 ImageReadParam param)
878 throws IIOException {
879
880 // If we are rearranging channels at all, the default
881 // conversions remain in place. If the user wants
882 // raw channels then he should do this while reading
883 // a Raster.
884 if (param != null) {
885 if ((param.getSourceBands() != null) ||
886 (param.getDestinationBands() != null)) {
887 // Accept default conversions out of decoder, silently
888 return;
889 }
890 }
1377 void thumbnailProgress(float percentageDone) {
1378 cbLock.lock();
1379 try {
1380 processThumbnailProgress(percentageDone);
1381 } finally {
1382 cbLock.unlock();
1383 }
1384 }
1385
1386 // Provide access to protected superclass method
1387 void thumbnailComplete() {
1388 cbLock.lock();
1389 try {
1390 processThumbnailComplete();
1391 } finally {
1392 cbLock.unlock();
1393 }
1394 }
1395
1396 /**
1397 * Returns <code>true</code> if the read was aborted.
1398 */
1399 private native boolean readImage(long structPointer,
1400 byte [] buffer,
1401 int numRasterBands,
1402 int [] srcBands,
1403 int [] bandSizes,
1404 int sourceXOffset, int sourceYOffset,
1405 int sourceWidth, int sourceHeight,
1406 int periodX, int periodY,
1407 JPEGQTable [] abbrevQTables,
1408 JPEGHuffmanTable [] abbrevDCHuffmanTables,
1409 JPEGHuffmanTable [] abbrevACHuffmanTables,
1410 int minProgressivePass,
1411 int maxProgressivePass,
1412 boolean wantUpdates);
1413
1414 public void abort() {
1415 setThreadLock();
1416 try {
1417 /**
|
527 private void skipImage() throws IOException {
528 if (debug) {
529 System.out.println("skipImage called");
530 }
531 boolean foundFF = false;
532 for (int byteval = iis.read();
533 byteval != -1;
534 byteval = iis.read()) {
535
536 if (foundFF == true) {
537 if (byteval == JPEG.EOI) {
538 return;
539 }
540 }
541 foundFF = (byteval == 0xff) ? true : false;
542 }
543 throw new IndexOutOfBoundsException();
544 }
545
546 /**
547 * Returns {@code true} if there is an image beyond
548 * the current stream position. Does not disturb the
549 * stream position.
550 */
551 private boolean hasNextImage() throws IOException {
552 if (debug) {
553 System.out.print("hasNextImage called; returning ");
554 }
555 iis.mark();
556 boolean foundFF = false;
557 for (int byteval = iis.read();
558 byteval != -1;
559 byteval = iis.read()) {
560
561 if (foundFF == true) {
562 if (byteval == JPEG.SOI) {
563 iis.reset();
564 if (debug) {
565 System.out.println("true");
566 }
567 return true;
597
598 /**
599 * Reads header information for the given image, if possible.
600 */
601 private void readHeader(int imageIndex, boolean reset)
602 throws IOException {
603 gotoImage(imageIndex);
604 readNativeHeader(reset); // Ignore return
605 currentImage = imageIndex;
606 }
607
608 private boolean readNativeHeader(boolean reset) throws IOException {
609 boolean retval = false;
610 retval = readImageHeader(structPointer, haveSeeked, reset);
611 haveSeeked = false;
612 return retval;
613 }
614
615 /**
616 * Read in the header information starting from the current
617 * stream position, returning {@code true} if the
618 * header was a tables-only image. After this call, the
619 * native IJG decompression struct will contain the image
620 * information required by most query calls below
621 * (e.g. getWidth, getHeight, etc.), if the header was not
622 * a tables-only image.
623 * If reset is {@code true}, the state of the IJG
624 * object is reset so that it can read a header again.
625 * This happens automatically if the header was a tables-only
626 * image.
627 */
628 private native boolean readImageHeader(long structPointer,
629 boolean clearBuffer,
630 boolean reset)
631 throws IOException;
632
633 /*
634 * Called by the native code whenever an image header has been
635 * read. Whether we read metadata or not, we always need this
636 * information, so it is passed back independently of
637 * metadata, which may never be read.
638 */
639 private void setImageData(int width,
640 int height,
641 int colorSpaceCode,
642 int outColorSpaceCode,
643 int numComponents,
850
851 }
852
853 list.add(getImageType(JPEG.JCS_GRAYSCALE));
854 list.add(getImageType(JPEG.JCS_YCC));
855 break;
856 case JPEG.JCS_YCbCrA: // Default is to convert to RGBA
857 // As there is no YCbCr ColorSpace, we can't support
858 // the raw type.
859 list.add(getImageType(JPEG.JCS_RGBA));
860 break;
861 }
862
863 return new ImageTypeIterator(list.iterator());
864 }
865
866 /**
867 * Checks the implied color conversion between the stream and
868 * the target image, altering the IJG output color space if necessary.
869 * If a java color conversion is required, then this sets up
870 * {@code convert}.
871 * If bands are being rearranged at all (either source or destination
872 * bands are specified in the param), then the default color
873 * conversions are assumed to be correct.
874 * Throws an IIOException if there is no conversion available.
875 */
876 private void checkColorConversion(BufferedImage image,
877 ImageReadParam param)
878 throws IIOException {
879
880 // If we are rearranging channels at all, the default
881 // conversions remain in place. If the user wants
882 // raw channels then he should do this while reading
883 // a Raster.
884 if (param != null) {
885 if ((param.getSourceBands() != null) ||
886 (param.getDestinationBands() != null)) {
887 // Accept default conversions out of decoder, silently
888 return;
889 }
890 }
1377 void thumbnailProgress(float percentageDone) {
1378 cbLock.lock();
1379 try {
1380 processThumbnailProgress(percentageDone);
1381 } finally {
1382 cbLock.unlock();
1383 }
1384 }
1385
1386 // Provide access to protected superclass method
1387 void thumbnailComplete() {
1388 cbLock.lock();
1389 try {
1390 processThumbnailComplete();
1391 } finally {
1392 cbLock.unlock();
1393 }
1394 }
1395
1396 /**
1397 * Returns {@code true} if the read was aborted.
1398 */
1399 private native boolean readImage(long structPointer,
1400 byte [] buffer,
1401 int numRasterBands,
1402 int [] srcBands,
1403 int [] bandSizes,
1404 int sourceXOffset, int sourceYOffset,
1405 int sourceWidth, int sourceHeight,
1406 int periodX, int periodY,
1407 JPEGQTable [] abbrevQTables,
1408 JPEGHuffmanTable [] abbrevDCHuffmanTables,
1409 JPEGHuffmanTable [] abbrevACHuffmanTables,
1410 int minProgressivePass,
1411 int maxProgressivePass,
1412 boolean wantUpdates);
1413
1414 public void abort() {
1415 setThreadLock();
1416 try {
1417 /**
|