diff --git a/components/formats-gpl/src/loci/formats/in/CellSensReader.java b/components/formats-gpl/src/loci/formats/in/CellSensReader.java index c07af03329f..04cf9190152 100644 --- a/components/formats-gpl/src/loci/formats/in/CellSensReader.java +++ b/components/formats-gpl/src/loci/formats/in/CellSensReader.java @@ -42,6 +42,7 @@ import loci.formats.FormatReader; import loci.formats.FormatTools; import loci.formats.IFormatReader; +import loci.formats.ImageTools; import loci.formats.MetadataTools; import loci.formats.codec.Codec; import loci.formats.codec.CodecOptions; @@ -405,6 +406,7 @@ public class CellSensReader extends FormatReader { private int previousTag = 0; private ArrayList pyramids = new ArrayList(); + private boolean[] bgr; private transient boolean expectETS = false; private transient int channelCount = 0; @@ -536,8 +538,8 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) Region intersection = null; byte[] tileBuf = null; - int pixel = - getRGBChannelCount() * FormatTools.getBytesPerPixel(getPixelType()); + int bpp = FormatTools.getBytesPerPixel(getPixelType()); + int pixel = getRGBChannelCount() * bpp; int outputRowLen = w * pixel; Pyramid pyramid = getCurrentPyramid(); @@ -588,6 +590,10 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) } } + if (bgr[getCurrentPyramidIndex()]) { + ImageTools.bgrToRgb(buf, isInterleaved(), bpp, getRGBChannelCount()); + } + return buf; } else { @@ -633,6 +639,7 @@ public void close(boolean fileOnly) throws IOException { pyramids.clear(); channelCount = 0; zCount = 0; + bgr = null; } } @@ -755,6 +762,7 @@ else if (zCount > 0) { IFDList exifs = parser.getExifIFDs(); + bgr = new boolean[seriesCount]; int index = 0; for (int s=0; s 1;