/** * As {@link #saveImg(String, Img)} with configuration options. * * @param id * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public Metadata saveImg(final String id, final Img<?> img, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { return saveImg(id, utils().makeSCIFIOImgPlus(img), 0, config); }
/** * As {@link #saveImg(String, SCIFIOImgPlus, int)} with configuration options. * * @param id * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public Metadata saveImg(final String id, final SCIFIOImgPlus<?> img, final int imageIndex, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { return writeImg(id, null, img, imageIndex, config); }
/** * {@link Writer} and {@link Img} provided * * @param w * @param img * @throws ImgIOException * @throws IncompatibleTypeException */ public void saveImg(final Writer w, final Img<?> img) throws ImgIOException, IncompatibleTypeException { saveImg(w, img, null); }
validate(mOut, w); final int planeCount = getPlaneCount(img); if (planeOutCount < planeCount / rgbChannelCount) { final FinalInterval bounds = new FinalInterval(planarMin, planarMax); final ByteArrayPlane destPlane = new ByteArrayPlane(getContext(), meta.get(imageIndex), bounds); getPlaneArray(img, rgbChannelCount, cIndex, planeIndex);
/** * Entry {@link #writeImg} method. Gathers necessary metadata, creates default * configuration options if needed, and delegates to the appropriate * intermediate {@link #writeImg} method if able. */ private Metadata writeImg(final String id, final Writer w, final SCIFIOImgPlus<?> img, final int imageIndex, SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { // Create the SCIFIOConfig if needed if (config == null) { config = new SCIFIOConfig(); } final int sliceCount = countSlices(img); if (w == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "No output destination or pre-configured Writer was provided, and" + " no way to determine the desired output path. Default value:" + " ImgPlus's source."); } return writeImg(id, img, imageIndex, config, sliceCount); } return writeImg(w, id, img, imageIndex, config, sliceCount); }
/** * Intermediate {@link #writeImg} method. Ensures the given writer has proper * {@link Metadata}, or creates it if possible. */ private Metadata writeImg(final Writer w, final String id, final SCIFIOImgPlus<?> imgPlus, final int imageIndex, final SCIFIOConfig config, final int sliceCount) throws ImgIOException, IncompatibleTypeException { if (w.getMetadata() == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "A Writer with no Metadata was provided, with no way to determine " + "the desired output path. Default value: ImgPlus's source."); } try { populateMeta(w, imgPlus, config, id, imageIndex); } catch (final FormatException e) { throw new ImgIOException(e, "SCIFIO exception when writing to file " + id + ":\n" + e.getMessage()); } catch (final IOException e) { throw new ImgIOException(e, "I/O exception writing to file " + id + ":\n" + e.getMessage()); } } return writeImg(w, imgPlus, imageIndex, sliceCount); }
final int pixelType = utils().makeType(img.firstElement());
/** * String id provided. {@link ImgPlus} provided, or wrapped {@link Img} in * previous saveImg. * * @param id * @param img * @throws ImgIOException * @throws IncompatibleTypeException */ public Metadata saveImg(final String id, final SCIFIOImgPlus<?> img, final int imageIndex) throws ImgIOException, IncompatibleTypeException { return saveImg(id, img, imageIndex, null); }
validate(mOut, w); final int planeCount = getPlaneCount(img); if (planeOutCount < planeCount / rgbChannelCount) { final FinalInterval bounds = new FinalInterval(planarMin, planarMax); final ByteArrayPlane destPlane = new ByteArrayPlane(getContext(), meta.get(imageIndex), bounds); getPlaneArray(img, rgbChannelCount, cIndex, planeIndex);
/** * Entry {@link #writeImg} method. Gathers necessary metadata, creates default * configuration options if needed, and delegates to the appropriate * intermediate {@link #writeImg} method if able. */ private Metadata writeImg(final String id, final Writer w, final SCIFIOImgPlus<?> img, final int imageIndex, SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { // Create the SCIFIOConfig if needed if (config == null) { config = new SCIFIOConfig(); } final int sliceCount = countSlices(img); if (w == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "No output destination or pre-configured Writer was provided, and" + " no way to determine the desired output path. Default value:" + " ImgPlus's source."); } return writeImg(id, img, imageIndex, config, sliceCount); } return writeImg(w, id, img, imageIndex, config, sliceCount); }
/** * Intermediate {@link #writeImg} method. Ensures the given writer has proper * {@link Metadata}, or creates it if possible. */ private Metadata writeImg(final Writer w, final String id, final SCIFIOImgPlus<?> imgPlus, final int imageIndex, final SCIFIOConfig config, final int sliceCount) throws ImgIOException, IncompatibleTypeException { if (w.getMetadata() == null) { if (id == null || id.length() == 0) { throw new ImgIOException( "A Writer with no Metadata was provided, with no way to determine " + "the desired output path. Default value: ImgPlus's source."); } try { populateMeta(w, imgPlus, config, id, imageIndex); } catch (final FormatException e) { throw new ImgIOException(e, "SCIFIO exception when writing to file " + id + ":\n" + e.getMessage()); } catch (final IOException e) { throw new ImgIOException(e, "I/O exception writing to file " + id + ":\n" + e.getMessage()); } } return writeImg(w, imgPlus, imageIndex, sliceCount); }
final int pixelType = utils().makeType(img.firstElement());
/** * @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); } }
/** * As {@link #saveImg(Writer, Img)}, with configuration options. * * @param w * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public void saveImg(final Writer w, final Img<?> img, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { saveImg(w, utils().makeSCIFIOImgPlus(img), 0, config); }
/** * {@link Writer} provided. {@link ImgPlus} provided, or wrapped provided * {@link Img}. * * @param w * @param img * @throws ImgIOException * @throws IncompatibleTypeException */ public void saveImg(final Writer w, final SCIFIOImgPlus<?> img, final int imageIndex) throws ImgIOException, IncompatibleTypeException { saveImg(w, img, imageIndex, null); }
/** * As {@link #saveImg(String, SCIFIOImgPlus, int)} with configuration options. * * @param id * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public Metadata saveImg(final String id, final SCIFIOImgPlus<?> img, final int imageIndex, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { return writeImg(id, null, img, imageIndex, config); }
/** * @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); } }
/** * As {@link #saveImg(Writer, Img)}, with configuration options. * * @param w * @param img * @param config Configuration information to use for this write. * @throws ImgIOException * @throws IncompatibleTypeException */ public void saveImg(final Writer w, final Img<?> img, final SCIFIOConfig config) throws ImgIOException, IncompatibleTypeException { saveImg(w, utils().makeSCIFIOImgPlus(img), 0, config); }