From 5dc6fc60c3fa44111bdfb4a2c2206c86f28b1326 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Mon, 27 Jul 2020 10:26:55 -0500 Subject: [PATCH] Fix sample format tag to preserve floating point pixel type See https://github.com/glencoesoftware/bioformats2raw/issues/52#issuecomment-664455674 --- .../pyramid/PyramidFromDirectoryWriter.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/glencoesoftware/pyramid/PyramidFromDirectoryWriter.java b/src/main/java/com/glencoesoftware/pyramid/PyramidFromDirectoryWriter.java index 468a9ac..d5a1039 100755 --- a/src/main/java/com/glencoesoftware/pyramid/PyramidFromDirectoryWriter.java +++ b/src/main/java/com/glencoesoftware/pyramid/PyramidFromDirectoryWriter.java @@ -851,7 +851,16 @@ private IFD makeIFD(PyramidSeries s, int resolution, int plane) ifd.put(IFD.COMPRESSION, getTIFFCompression().getCode()); ifd.put(IFD.PLANAR_CONFIGURATION, s.rgb ? 2 : 1); - ifd.put(IFD.SAMPLE_FORMAT, 1); + + int sampleFormat = 1; + if (FormatTools.isFloatingPoint(s.pixelType)) { + sampleFormat = 3; + } + else if (FormatTools.isSigned(s.pixelType)) { + sampleFormat = 2; + } + + ifd.put(IFD.SAMPLE_FORMAT, sampleFormat); int[] bps = new int[s.rgb ? s.c : 1]; Arrays.fill(bps, FormatTools.getBytesPerPixel(s.pixelType) * 8);