perform auto scalling if 16bit or gray scale thumbnail image.

This commit is contained in:
Yoshihiro OKUMURA 2022-10-12 19:42:09 +09:00
parent 0df492ff14
commit b8bfa77cc2

View File

@ -21,7 +21,6 @@ import javax.imageio.stream.ImageOutputStream;
import loci.common.DebugTools; import loci.common.DebugTools;
import loci.formats.FormatException; import loci.formats.FormatException;
import loci.formats.FormatTools;
import loci.formats.ImageReader; import loci.formats.ImageReader;
import loci.formats.gui.AWTImageTools; import loci.formats.gui.AWTImageTools;
import loci.formats.gui.BufferedImageReader; import loci.formats.gui.BufferedImageReader;
@ -179,13 +178,15 @@ public class BioFormatsImageThumbnail {
// System.out.println("resolution: " + reader.getResolutionCount()); // System.out.println("resolution: " + reader.getResolutionCount());
// System.out.println("thubmail series: " + series); // System.out.println("thubmail series: " + series);
ret = reader.openThumbImage(no); ret = reader.openThumbImage(no);
if (!FormatTools.isFloatingPoint(reader.getPixelType())) { final boolean is16bit = reader.getBitsPerPixel() > 8;
// auto scalling floating point thumbnail. final boolean isGrayScale = ret.getSampleModel().getNumBands() == 1;
if (is16bit || isGrayScale) {
// perform auto scalling if 16bit or gray scale thumbnail image.
ret = AWTImageTools.autoscale(ret); ret = AWTImageTools.autoscale(ret);
} }
} catch (final Throwable t) { } catch (final Throwable t) {
for (Throwable e = t; e != null; e = e.getCause()) { for (Throwable e = t; e != null; e = e.getCause()) {
if (t instanceof OutOfMemoryError) { if (e instanceof OutOfMemoryError) {
throw new BioFormatsImageException("out of memory"); throw new BioFormatsImageException("out of memory");
} }
} }