Skip to content

Commit

Permalink
Merge pull request #39 from melissalinkert/float-pixels
Browse files Browse the repository at this point in the history
Fix sample format tag to preserve floating point pixel type
  • Loading branch information
chris-allan authored Jul 30, 2020
2 parents 17debd6 + 5dc6fc6 commit ed49988
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ed49988

Please sign in to comment.