#374 Added support for TIFF 32 bit float Grayscale

This commit is contained in:
Harald Kuhr 2017-10-16 14:52:40 +02:00
parent c1fac78f3c
commit a15e69e019
2 changed files with 44 additions and 2 deletions

View File

@ -112,6 +112,9 @@ public final class ImageTypeSpecifiers {
// As the ComponentColorModel is broken for 32 bit unsigned int, we'll use our own version // As the ComponentColorModel is broken for 32 bit unsigned int, we'll use our own version
return UInt32ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {0}, false, false); return UInt32ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {0}, false, false);
} }
else if (dataType == DataBuffer.TYPE_FLOAT || dataType == DataBuffer.TYPE_DOUBLE) {
return ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {0}, dataType, false, false);
}
// NOTE: The isSigned boolean is stored but *not used for anything* in the Grayscale ImageTypeSpecifier... // NOTE: The isSigned boolean is stored but *not used for anything* in the Grayscale ImageTypeSpecifier...
return ImageTypeSpecifier.createGrayscale(bits, dataType, false); return ImageTypeSpecifier.createGrayscale(bits, dataType, false);
@ -126,6 +129,9 @@ public final class ImageTypeSpecifiers {
// As the ComponentColorModel is broken for 32 bit unsigned int, we'll use our own version // As the ComponentColorModel is broken for 32 bit unsigned int, we'll use our own version
return UInt32ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {0, 1}, true, isAlphaPremultiplied); return UInt32ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {0, 1}, true, isAlphaPremultiplied);
} }
else if (dataType == DataBuffer.TYPE_FLOAT || dataType == DataBuffer.TYPE_DOUBLE) {
return ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[] {0, 1}, dataType, true, isAlphaPremultiplied);
}
// NOTE: The isSigned boolean is stored but *not used for anything* in the Grayscale ImageTypeSpecifier... // NOTE: The isSigned boolean is stored but *not used for anything* in the Grayscale ImageTypeSpecifier...
return ImageTypeSpecifier.createGrayscale(bits, dataType, false, isAlphaPremultiplied); return ImageTypeSpecifier.createGrayscale(bits, dataType, false, isAlphaPremultiplied);

View File

@ -386,9 +386,21 @@ public class ImageTypeSpecifiersTest {
UInt32ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0}, false, false), UInt32ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0}, false, false),
ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_INT) ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_INT)
); );
}
@Test
public void testCreateGrayscaleFloat() {
assertEquals( assertEquals(
UInt32ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0}, false, false), ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0}, DataBuffer.TYPE_FLOAT, false, false),
ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_INT) ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_FLOAT)
);
}
@Test
public void testCreateGrayscaleDouble() {
assertEquals(
ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0}, DataBuffer.TYPE_DOUBLE, false, false),
ImageTypeSpecifiers.createGrayscale(64, DataBuffer.TYPE_DOUBLE)
); );
} }
@ -463,6 +475,30 @@ public class ImageTypeSpecifiersTest {
); );
} }
@Test
public void testCreateGrayscaleAlphaFloat() {
assertEquals(
ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0, 1}, DataBuffer.TYPE_FLOAT, true, false),
ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_FLOAT, false)
);
assertEquals(
ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0, 1}, DataBuffer.TYPE_FLOAT, true, true),
ImageTypeSpecifiers.createGrayscale(32, DataBuffer.TYPE_FLOAT, true)
);
}
@Test
public void testCreateGrayscaleAlphaDouble() {
assertEquals(
ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0, 1}, DataBuffer.TYPE_DOUBLE, true, false),
ImageTypeSpecifiers.createGrayscale(64, DataBuffer.TYPE_DOUBLE, false)
);
assertEquals(
ImageTypeSpecifier.createInterleaved(GRAY, new int[] {0, 1}, DataBuffer.TYPE_DOUBLE, true, true),
ImageTypeSpecifiers.createGrayscale(64, DataBuffer.TYPE_DOUBLE, true)
);
}
@Test @Test
public void testCreatePackedGrayscale1() { public void testCreatePackedGrayscale1() {
assertEquals( assertEquals(