@Override public void saveStop() throws IOException { if (saveStream != null) { saveStream.close(); saveStream = null; } }
/** * Closes the output stream if not null. * @throws IOException Thrown if an error occurred while closing. */ public void close() throws IOException { if (out != null) { out.close(); } }
/** * Closes the output stream if not null. * @throws IOException Thrown if an error occurred while closing. */ public void close() throws IOException { if (out != null) { out.close(); } }
@Override public void saveStop() throws IOException { if (saveStream != null) { saveStream.close(); saveStream = null; } }
@Override public void close() throws IOException { if (out != null) out.close(); out = null; currentId = null; initialized = null; resolution = 0; resolutionData.clear(); }
@Override public void close() throws IOException { if (out != null) out.close(); out = null; currentId = null; initialized = null; resolution = 0; resolutionData.clear(); }
@Override public void close() throws IOException { super.close(); pixelOffset = 43; lastPlane = -1; if (pixels != null) { pixels.close(); } pixels = null; }
@Override public void close() throws IOException { super.close(); pixelOffset = 43; lastPlane = -1; if (pixels != null) { pixels.close(); } pixels = null; }
@Override public void close() throws IOException { super.close(); pixelOffset = 0; lastPlane = -1; dimensionOffset = 0; dimensionLength = 0; if (pixels != null) { pixels.close(); } pixels = null; uniqueFiles.clear(); }
@Override public void close() throws IOException { super.close(); pixelOffset = 0; lastPlane = -1; dimensionOffset = 0; dimensionLength = 0; if (pixels != null) { pixels.close(); } pixels = null; uniqueFiles.clear(); }
@AfterMethod public void tearDown() throws IOException { in.close(); out.close(); }
private void saveComment(String file, String xml) throws IOException { if (out != null) out.close(); out = new RandomAccessOutputStream(file); RandomAccessInputStream in = null; try { TiffSaver saver = new TiffSaver(out, file); saver.setBigTiff(isBigTiff); in = new RandomAccessInputStream(file); saver.overwriteLastIFDOffset(in); saver.overwriteComment(in, xml); } catch (FormatException exc) { IOException io = new IOException("Unable to append OME-XML comment"); io.initCause(exc); throw io; } finally { if (out != null) out.close(); if (in != null) in.close(); } }
private void saveComment(String file, String xml) throws IOException { if (out != null) out.close(); out = new RandomAccessOutputStream(file); RandomAccessInputStream in = null; try { TiffSaver saver = new TiffSaver(out, file); saver.setBigTiff(isBigTiff); in = new RandomAccessInputStream(file); saver.overwriteLastIFDOffset(in); saver.overwriteComment(in, xml); } catch (FormatException exc) { IOException io = new IOException("Unable to append OME-XML comment"); io.initCause(exc); throw io; } finally { if (out != null) out.close(); if (in != null) in.close(); } }
/** * Initializes a writer from the input file name. * * Initializes a {@link RandomAccessOutputStream} for the output * file and initializes the metadata for all the series using * {@link #setSeries(int)}. * * @param id a {@link String} specifying the path to the file */ @Override public void setId(String id) throws FormatException, IOException { if (id.equals(currentId)) return; currentId = id; if (out != null) { out.close(); } out = createOutputStream(); MetadataRetrieve r = getMetadataRetrieve(); initialized = new boolean[r.getImageCount()][]; for (int i=0; i<r.getImageCount(); i++) { initialized[i] = new boolean[getPlaneCount(i)]; } resolution = 0; }
/** * Initializes a writer from the input file name. * * Initializes a {@link RandomAccessOutputStream} for the output * file and initializes the metadata for all the series using * {@link #setSeries(int)}. * * @param id a {@link String} specifying the path to the file */ @Override public void setId(String id) throws FormatException, IOException { if (id.equals(currentId)) return; currentId = id; if (out != null) { out.close(); } out = createOutputStream(); MetadataRetrieve r = getMetadataRetrieve(); initialized = new boolean[r.getImageCount()][]; for (int i=0; i<r.getImageCount(); i++) { initialized[i] = new boolean[getPlaneCount(i)]; } resolution = 0; }
public void writeIFD(IFD ifd, long nextOffset) throws FormatException, IOException { TreeSet<Integer> keys = new TreeSet<Integer>(ifd.keySet()); int keyCount = keys.size(); if (ifd.containsKey(new Integer(IFD.LITTLE_ENDIAN))) keyCount--; if (ifd.containsKey(new Integer(IFD.BIG_TIFF))) keyCount--; if (ifd.containsKey(new Integer(IFD.REUSE))) keyCount--; long fp = out.getFilePointer(); int bytesPerEntry = bigTiff ? TiffConstants.BIG_TIFF_BYTES_PER_ENTRY : TiffConstants.BYTES_PER_ENTRY; int ifdBytes = (bigTiff ? 16 : 6) + bytesPerEntry * keyCount; if (bigTiff) out.writeLong(keyCount); else out.writeShort(keyCount); ByteArrayHandle extra = new ByteArrayHandle(); RandomAccessOutputStream extraStream = new RandomAccessOutputStream(extra); for (Integer key : keys) { if (key.equals(IFD.LITTLE_ENDIAN) || key.equals(IFD.BIG_TIFF) || key.equals(IFD.REUSE)) continue; Object value = ifd.get(key); writeIFDValue(extraStream, ifdBytes + fp, key.intValue(), value); } if (bigTiff) out.seek(out.getFilePointer()); writeIntValue(out, nextOffset); out.write(extra.getBytes(), 0, (int) extra.length()); extraStream.close(); }
public void writeIFD(IFD ifd, long nextOffset) throws FormatException, IOException { TreeSet<Integer> keys = new TreeSet<Integer>(ifd.keySet()); int keyCount = keys.size(); if (ifd.containsKey(new Integer(IFD.LITTLE_ENDIAN))) keyCount--; if (ifd.containsKey(new Integer(IFD.BIG_TIFF))) keyCount--; if (ifd.containsKey(new Integer(IFD.REUSE))) keyCount--; long fp = out.getFilePointer(); int bytesPerEntry = bigTiff ? TiffConstants.BIG_TIFF_BYTES_PER_ENTRY : TiffConstants.BYTES_PER_ENTRY; int ifdBytes = (bigTiff ? 16 : 6) + bytesPerEntry * keyCount; if (bigTiff) out.writeLong(keyCount); else out.writeShort(keyCount); ByteArrayHandle extra = new ByteArrayHandle(); RandomAccessOutputStream extraStream = new RandomAccessOutputStream(extra); for (Integer key : keys) { if (key.equals(IFD.LITTLE_ENDIAN) || key.equals(IFD.BIG_TIFF) || key.equals(IFD.REUSE)) continue; Object value = ifd.get(key); writeIFDValue(extraStream, ifdBytes + fp, key.intValue(), value); } if (bigTiff) out.seek(out.getFilePointer()); writeIntValue(out, nextOffset); out.write(extra.getBytes(), 0, (int) extra.length()); extraStream.close(); }
out.close(); try (RandomAccessInputStream s = new RandomAccessInputStream(handle)) { s.seek(0);
protected void setupTiffSaver() throws IOException { out.close(); out = createOutputStream(); tiffSaver = createTiffSaver(); MetadataRetrieve retrieve = getMetadataRetrieve(); boolean littleEndian = false; if (retrieve.getPixelsBigEndian(series) != null) { littleEndian = !retrieve.getPixelsBigEndian(series).booleanValue(); } else if (retrieve.getPixelsBinDataCount(series) == 0) { littleEndian = !retrieve.getPixelsBinDataBigEndian(series, 0).booleanValue(); } tiffSaver.setWritingSequentially(sequential); tiffSaver.setLittleEndian(littleEndian); tiffSaver.setBigTiff(isBigTiff); tiffSaver.setCodecOptions(options); }
protected void setupTiffSaver() throws IOException { out.close(); out = createOutputStream(); tiffSaver = createTiffSaver(); MetadataRetrieve retrieve = getMetadataRetrieve(); boolean littleEndian = false; if (retrieve.getPixelsBigEndian(series) != null) { littleEndian = !retrieve.getPixelsBigEndian(series).booleanValue(); } else if (retrieve.getPixelsBinDataCount(series) == 0) { littleEndian = !retrieve.getPixelsBinDataBigEndian(series, 0).booleanValue(); } tiffSaver.setWritingSequentially(sequential); tiffSaver.setLittleEndian(littleEndian); tiffSaver.setBigTiff(isBigTiff); tiffSaver.setCodecOptions(options); }