use of loci.common.RandomAccessOutputStream in project bioformats by openmicroscopy.
the class TiffPixelsTest method readSavedPlane.
// -- Helper method --
private byte[] readSavedPlane() throws FormatException, IOException {
ByteArrayHandle savedData = new ByteArrayHandle();
RandomAccessOutputStream out = new RandomAccessOutputStream(savedData);
RandomAccessInputStream in = new RandomAccessInputStream(savedData);
TiffSaver saver = new TiffSaver(out, savedData);
// saver.setInputStream(in);
saver.writeImage(data, ifd, 0, FormatTools.UINT16, false);
out.close();
TiffParser parser = new TiffParser(in);
byte[] plane = new byte[data.length];
parser.getSamples(ifd, plane);
in.close();
return plane;
}
use of loci.common.RandomAccessOutputStream in project bioformats by openmicroscopy.
the class TiffSaverTest method testNullFilename.
@Test(expectedExceptions = { IllegalArgumentException.class })
public void testNullFilename() throws IOException {
RandomAccessOutputStream a = new RandomAccessOutputStream(new ByteArrayHandle());
String b = null;
tiffSaver = new TiffSaver(a, b);
tiffSaver.writeHeader();
}
use of loci.common.RandomAccessOutputStream in project bioformats by openmicroscopy.
the class TiffSaverTest method testNullBytes.
@Test(expectedExceptions = { IllegalArgumentException.class })
public void testNullBytes() throws IOException {
RandomAccessOutputStream a = new RandomAccessOutputStream(new ByteArrayHandle());
ByteArrayHandle b = null;
tiffSaver = new TiffSaver(a, b);
tiffSaver.writeHeader();
}
use of loci.common.RandomAccessOutputStream in project bioformats by openmicroscopy.
the class TiffSaverTest method testNullOutputStream.
@Test(expectedExceptions = { IllegalArgumentException.class })
public void testNullOutputStream() throws IOException {
RandomAccessOutputStream a = null;
String b = null;
tiffSaver = new TiffSaver(a, b);
tiffSaver.writeHeader();
}
use of loci.common.RandomAccessOutputStream in project bioformats by openmicroscopy.
the class TiffComment method overwriteComment.
/**
* Overwrites the comment.
*
* @param file The path to the file to handle.
* @param comment The new comment to write.
*/
private static void overwriteComment(String file, String comment) {
RandomAccessInputStream in = null;
RandomAccessOutputStream out = null;
try {
in = new RandomAccessInputStream(file);
out = new RandomAccessOutputStream(file);
TiffSaver saver = new TiffSaver(out, file);
saver.overwriteComment(in, comment);
} catch (Exception e) {
System.out.println(e.toString());
} finally {
try {
if (in != null)
in.close();
} catch (Exception e) {
}
try {
if (out != null)
out.close();
} catch (Exception e) {
}
}
}
Aggregations