/** * @see ImgSaver#saveImg(String, Img) */ public static void saveImg(final String dest, final Img<?> img) { try { new ImgSaver().saveImg(dest, img); } catch (final IncompatibleTypeException e) { saveError(dest, e); } catch (final ImgIOException e) { saveError(dest, e); } }
@Override public Metadata save(final Dataset dataset, final String destination, final SCIFIOConfig config) throws IOException { @SuppressWarnings("rawtypes") final ImgPlus img = dataset.getImgPlus(); final Metadata metadata; final ImgSaver imageSaver = new ImgSaver(getContext()); try { metadata = imageSaver.saveImg(destination, img, config); } catch (final ImgIOException exc) { throw new IOException(exc); } catch (final IncompatibleTypeException exc) { throw new IOException(exc); } final String name = new File(destination).getName(); dataset.setName(name); dataset.setDirty(false); return metadata; }
/** * @see ImgSaver#saveImg(String, SCIFIOImgPlus, int) */ public static void saveImg(final String dest, final SCIFIOImgPlus<?> imgPlus, final int imageIndex) { try { new ImgSaver().saveImg(dest, imgPlus, imageIndex); } catch (final IncompatibleTypeException e) { saveError(dest, e); } catch (final ImgIOException e) { saveError(dest, e); } }
/** * @see ImgSaver#saveImg(String, SCIFIOImgPlus, int) */ public static void saveImg(final String dest, final SCIFIOImgPlus<?> imgPlus, final int imageIndex) { try { new ImgSaver().saveImg(dest, imgPlus, imageIndex); } catch (final IncompatibleTypeException e) { saveError(dest, e); } catch (final ImgIOException e) { saveError(dest, e); } }
/** * @see ImgSaver#saveImg(String, Img) */ public static void saveImg(final String dest, final Img<?> img) { try { new ImgSaver().saveImg(dest, img); } catch (final IncompatibleTypeException e) { saveError(dest, e); } catch (final ImgIOException e) { saveError(dest, e); } }
@Override public Metadata save(final Dataset dataset, final String destination, final SCIFIOConfig config) throws IOException { @SuppressWarnings("rawtypes") final ImgPlus img = dataset.getImgPlus(); final Metadata metadata; final ImgSaver imageSaver = new ImgSaver(getContext()); try { metadata = imageSaver.saveImg(destination, img, config); } catch (final ImgIOException exc) { throw new IOException(exc); } catch (final IncompatibleTypeException exc) { throw new IOException(exc); } final String name = new File(destination).getName(); dataset.setName(name); dataset.setDirty(false); return metadata; }
/** * @see ImgSaver#saveImg(Writer, Img) */ public static void saveImg(final Writer writer, final Img<?> img) { try { new ImgSaver().saveImg(writer, img); } catch (final IncompatibleTypeException e) { saveError(writer.getMetadata().getDatasetName(), e); } catch (final ImgIOException e) { saveError(writer.getMetadata().getDatasetName(), e); } }
/** * @see ImgSaver#saveImg(Writer, Img) */ public static void saveImg(final Writer writer, final Img<?> img) { try { new ImgSaver().saveImg(writer, img); } catch (final IncompatibleTypeException e) { saveError(writer.getMetadata().getDatasetName(), e); } catch (final ImgIOException e) { saveError(writer.getMetadata().getDatasetName(), e); } }
private static void convertImg(final File file) throws Exception { final Context c = new Context(); final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes(ImgMode.ARRAY); final ImgPlus<?> img = new ImgOpener(c).openImgs(file.getAbsolutePath(), config).get(0); final String outPath = file.getParent() + File.separator + "out_" + img.getName(); new ImgSaver(c).saveImg(outPath, img); c.dispose(); }
/** * @see ImgSaver#saveImg(Writer, SCIFIOImgPlus, int) */ public static void saveImg(final Writer writer, final SCIFIOImgPlus<?> imgPlus, final int imageIndex) { try { new ImgSaver().saveImg(writer, imgPlus, imageIndex); } catch (final IncompatibleTypeException e) { saveError(writer.getMetadata().getDatasetName(), e); } catch (final ImgIOException e) { saveError(writer.getMetadata().getDatasetName(), e); } }
/** * @see ImgSaver#saveImg(Writer, SCIFIOImgPlus, int) */ public static void saveImg(final Writer writer, final SCIFIOImgPlus<?> imgPlus, final int imageIndex) { try { new ImgSaver().saveImg(writer, imgPlus, imageIndex); } catch (final IncompatibleTypeException e) { saveError(writer.getMetadata().getDatasetName(), e); } catch (final ImgIOException e) { saveError(writer.getMetadata().getDatasetName(), e); } }
private void testPlaneSavingForConfig(final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { final ImgOpener o = new ImgOpener(ctx); final ImgSaver s = new ImgSaver(ctx); // write the image final SCIFIOImgPlus<UnsignedByteType> before = o.openImgs(id, new UnsignedByteType(), config).get(0); s.saveImg(out, before); // re-read the written image and check for consistency final SCIFIOImgPlus<UnsignedByteType> after = o.openImgs(out, new UnsignedByteType()).get(0); assertImagesEqual(before, after); }
/** * Write an image to memory using the {@link ImgSaver} and verify that the * given {@link ImgPlus} is not corrupted during the process. */ @Test public void testImgPlusIntegrity() throws ImgIOException, IncompatibleTypeException { final ImgOpener o = new ImgOpener(ctx); final ImgSaver s = new ImgSaver(ctx); final SCIFIOConfig config = new SCIFIOConfig().imgOpenerSetImgModes( ImgMode.PLANAR); final ByteArrayHandle bah = new ByteArrayHandle(); locationService.mapFile(out, bah); final SCIFIOImgPlus<?> openImg = o.openImgs(id, config).get(0); final String source = openImg.getSource(); s.saveImg(out, openImg); assertEquals(source, openImg.getSource()); }