diff --git a/components/formats-bsd/src/loci/formats/tiff/TiffSaver.java b/components/formats-bsd/src/loci/formats/tiff/TiffSaver.java index f803895bca2..06c01da240b 100644 --- a/components/formats-bsd/src/loci/formats/tiff/TiffSaver.java +++ b/components/formats-bsd/src/loci/formats/tiff/TiffSaver.java @@ -350,15 +350,22 @@ public void writeImage(byte[] buf, IFD ifd, int no, int pixelType, int x, stripOut[strip].write(buf, strip * stripSize, stripSize); } } else { - for (int strip = 0; strip < nStrips - 1; strip++) { - stripOut[strip].write(buf, strip * stripSize, stripSize); - } - // Sigh. Need to pad the last strip. - int pos = (nStrips - 1) * stripSize; - int len = buf.length - pos; - stripOut[nStrips - 1].write(buf, pos, len); - for (int n = len; n < stripSize; n++) { - stripOut[nStrips - 1].writeByte(0); + int effectiveStrips = !interleaved ? nStrips / nChannels : nStrips; + int planarChannels = !interleaved ? nChannels : 1; + int totalBytesPerChannel = buf.length / planarChannels; + for (int p=0; p