2998 if (stream == null) {
2999 throw new IllegalStateException("Output not set!");
3000 }
3001 if (imageIndex < 0) {
3002 throw new IndexOutOfBoundsException("imageIndex < 0!");
3003 }
3004
3005 stream.mark();
3006 long[] ifdpos = new long[1];
3007 long[] ifd = new long[1];
3008 locateIFD(imageIndex, ifdpos, ifd);
3009 if (ifd[0] == 0) {
3010 stream.reset();
3011 throw new IndexOutOfBoundsException
3012 ("imageIndex out of bounds!");
3013 }
3014
3015 List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1);
3016 tagSets.add(BaselineTIFFTagSet.getInstance());
3017 TIFFIFD rootIFD = new TIFFIFD(tagSets);
3018 rootIFD.initialize(stream, true, true);
3019 stream.reset();
3020
3021 return rootIFD;
3022 }
3023
3024 public boolean canReplacePixels(int imageIndex) throws IOException {
3025 if (getOutput() == null) {
3026 throw new IllegalStateException("getOutput() == null!");
3027 }
3028
3029 TIFFIFD rootIFD = readIFD(imageIndex);
3030 TIFFField f = rootIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
3031 int compression = f.getAsInt(0);
3032
3033 return compression == BaselineTIFFTagSet.COMPRESSION_NONE;
3034 }
3035
3036 private Object replacePixelsLock = new Object();
3037
3038 private int replacePixelsIndex = -1;
|
2998 if (stream == null) {
2999 throw new IllegalStateException("Output not set!");
3000 }
3001 if (imageIndex < 0) {
3002 throw new IndexOutOfBoundsException("imageIndex < 0!");
3003 }
3004
3005 stream.mark();
3006 long[] ifdpos = new long[1];
3007 long[] ifd = new long[1];
3008 locateIFD(imageIndex, ifdpos, ifd);
3009 if (ifd[0] == 0) {
3010 stream.reset();
3011 throw new IndexOutOfBoundsException
3012 ("imageIndex out of bounds!");
3013 }
3014
3015 List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1);
3016 tagSets.add(BaselineTIFFTagSet.getInstance());
3017 TIFFIFD rootIFD = new TIFFIFD(tagSets);
3018 rootIFD.initialize(stream, true, false, false);
3019 stream.reset();
3020
3021 return rootIFD;
3022 }
3023
3024 public boolean canReplacePixels(int imageIndex) throws IOException {
3025 if (getOutput() == null) {
3026 throw new IllegalStateException("getOutput() == null!");
3027 }
3028
3029 TIFFIFD rootIFD = readIFD(imageIndex);
3030 TIFFField f = rootIFD.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
3031 int compression = f.getAsInt(0);
3032
3033 return compression == BaselineTIFFTagSet.COMPRESSION_NONE;
3034 }
3035
3036 private Object replacePixelsLock = new Object();
3037
3038 private int replacePixelsIndex = -1;
|