Skip to content

Commit

Permalink
TIFFFormat: correct pixel type calculation
Browse files Browse the repository at this point in the history
When using the TIFFFormat translator, the float pixel type wasn't being
considered properly.

Updated the translator logic to set the IFD SAMPLE_FORMAT field
appropriately for float data.

Reported and fixed by Brian Northan (bnorthan)
  • Loading branch information
hinerm committed Dec 12, 2013
1 parent c343e83 commit ece33cc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scifio/src/main/java/io/scif/formats/TIFFFormat.java
Expand Up @@ -1552,10 +1552,21 @@ public void typedTranslate(final io.scif.Metadata source,

final IFD firstIFD = ifds.get(0);

// Determine pixel type. Decoding logic is in IFD#getPixelType
int sampleFormat;
if (FormatTools.isFloatingPoint(m.getPixelType())) {
sampleFormat = 3;
}
else if (FormatTools.isSigned(m.getPixelType())) {
sampleFormat = 2;
}
else {
sampleFormat = 1;
}

firstIFD.putIFDValue(IFD.BITS_PER_SAMPLE,
new int[] { m.getBitsPerPixel() });
firstIFD.putIFDValue(IFD.SAMPLE_FORMAT, FormatTools.isSigned(m
.getPixelType()) ? 2 : 1);
firstIFD.putIFDValue(IFD.SAMPLE_FORMAT, sampleFormat);
firstIFD.putIFDValue(IFD.LITTLE_ENDIAN, m.isLittleEndian());
firstIFD.putIFDValue(IFD.IMAGE_WIDTH, m.getAxisLength(Axes.X));
firstIFD.putIFDValue(IFD.IMAGE_LENGTH, m.getAxisLength(Axes.Y));
Expand Down

0 comments on commit ece33cc

Please sign in to comment.