diff --git a/components/formats-bsd/src/loci/formats/out/DicomWriter.java b/components/formats-bsd/src/loci/formats/out/DicomWriter.java index de3850248ea..d578d10e06c 100644 --- a/components/formats-bsd/src/loci/formats/out/DicomWriter.java +++ b/components/formats-bsd/src/loci/formats/out/DicomWriter.java @@ -500,6 +500,7 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) int bytesPerPixel = FormatTools.getBytesPerPixel( FormatTools.pixelTypeFromString( r.getPixelsType(series).toString())); + int samplesPerPixel = getSamplesPerPixel(); out.seek(out.length()); long start = out.getFilePointer(); @@ -512,9 +513,9 @@ public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) if ((x + w == getSizeX() && w < thisTileWidth) || (y + h == getSizeY() && h < thisTileHeight)) { - if (interleaved || getSamplesPerPixel() == 1) { - int srcRowLen = w * bytesPerPixel * getSamplesPerPixel(); - int destRowLen = thisTileWidth * bytesPerPixel * getSamplesPerPixel(); + if (interleaved || samplesPerPixel == 1) { + int srcRowLen = w * bytesPerPixel * samplesPerPixel; + int destRowLen = thisTileWidth * bytesPerPixel * samplesPerPixel; paddedBuf = new byte[thisTileHeight * destRowLen]; for (int row=0; row