diff --git a/components/bio-formats-tools/src/loci/formats/tools/ImageConverter.java b/components/bio-formats-tools/src/loci/formats/tools/ImageConverter.java index 8f1c3816929..29cb160d8fd 100644 --- a/components/bio-formats-tools/src/loci/formats/tools/ImageConverter.java +++ b/components/bio-formats-tools/src/loci/formats/tools/ImageConverter.java @@ -1228,6 +1228,14 @@ private boolean doTileConversion(IFormatWriter writer, String outputFile) if (writer instanceof DicomWriter || (writer instanceof ImageWriter && ((ImageWriter) writer).getWriter(outputFile) instanceof DicomWriter)) { + // if we asked to try a precompressed conversion, + // then the writer's tile sizes will have been set automatically + // according to the input data + // the conversion must then be performed tile-wise to match the tile sizes, + // even if precompression doesn't end up being possible + if (precompressed) { + return true; + } MetadataStore r = reader.getMetadataStore(); return !(r instanceof IPyramidStore) || ((IPyramidStore) r).getResolutionCount(reader.getSeries()) > 1; } diff --git a/components/formats-bsd/src/loci/formats/out/DicomWriter.java b/components/formats-bsd/src/loci/formats/out/DicomWriter.java index 275986a606a..96b4d6fcfee 100644 --- a/components/formats-bsd/src/loci/formats/out/DicomWriter.java +++ b/components/formats-bsd/src/loci/formats/out/DicomWriter.java @@ -235,14 +235,7 @@ public void saveCompressedBytes(int no, byte[] buf, int x, int y, int w, int h) LOGGER.debug("savePrecompressedBytes(series={}, resolution={}, no={}, x={}, y={})", series, resolution, no, x, y); - // TODO: may want better handling of non-tiled "extra" images (e.g. label, macro) MetadataRetrieve r = getMetadataRetrieve(); - if ((!(r instanceof IPyramidStore) || - ((IPyramidStore) r).getResolutionCount(series) == 1) && - !isFullPlane(x, y, w, h)) - { - throw new FormatException("DicomWriter does not allow tiles for non-pyramid images"); - } int bytesPerPixel = FormatTools.getBytesPerPixel( FormatTools.pixelTypeFromString( @@ -397,13 +390,7 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) int thisTileHeight = tileHeight[resolutionIndex]; MetadataRetrieve r = getMetadataRetrieve(); - if ((!(r instanceof IPyramidStore) || - ((IPyramidStore) r).getResolutionCount(series) == 1) && - !isFullPlane(x, y, w, h)) - { - throw new FormatException("DicomWriter does not allow tiles for non-pyramid images"); - } - else if (x % thisTileWidth != 0 || y % thisTileHeight != 0 || + if (x % thisTileWidth != 0 || y % thisTileHeight != 0 || (w != thisTileWidth && x + w != getSizeX()) || (h != thisTileHeight && y + h != getSizeY())) {