@Test public void testCreateIndexedByteArrays1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { byte[] lut = createByteLut(1 << bits); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_BYTE), ImageTypeSpecifiers.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_BYTE) ); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_BYTE), ImageTypeSpecifiers.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_BYTE) ); } }
@Test public void testCreateIndexedIntArray1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { int[] colors = createIntLut(1 << bits); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(bits, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE)), ImageTypeSpecifiers.createIndexed(colors, false, -1, bits, DataBuffer.TYPE_BYTE) ); } }
@Test public void testCreatePacked16() { // TYPE_USHORT_555_RGB assertEquals( createPacked(sRGB, DCM_555_RED_MASK, DCM_555_GRN_MASK, DCM_555_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false), ImageTypeSpecifiers.createPacked(sRGB, DCM_555_RED_MASK, DCM_555_GRN_MASK, DCM_555_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false) ); // "SHORT 555 RGB" (impossible, only BYTE, USHORT, INT supported) // TYPE_USHORT_565_RGB assertEquals( createPacked(sRGB, DCM_565_RED_MASK, DCM_565_GRN_MASK, DCM_565_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false), ImageTypeSpecifiers.createPacked(sRGB, DCM_565_RED_MASK, DCM_565_GRN_MASK, DCM_565_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false) ); // "USHORT 4444 ARGB" assertEquals( createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, false), ImageTypeSpecifiers.createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, false) ); // "USHORT 4444 ARGB PRE" assertEquals( createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, true), ImageTypeSpecifiers.createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, true) ); // Extra: Make sure color models bits is actually 16 (ImageTypeSpecifier equivalent returns 32) assertEquals(16, ImageTypeSpecifiers.createPacked(sRGB, DCM_565_RED_MASK, DCM_565_GRN_MASK, DCM_565_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false).getColorModel().getPixelSize()); }
@Test public void testCreateFromIndexedColorModel16() { int[] colors = createIntLut(1 << 16); IndexColorModel colorModel = new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(colorModel), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); }
@Test public void testCreateIndexedByteArrays32() { for (int bits = 1; bits <= 8; bits <<= 1) { byte[] lut = createByteLut(1 << bits); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_INT) ); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_INT) ); } byte[] lut = createByteLut(1 << 16); // This is stupid, but ImageTypeSpecifier enforces lut.length == 1 << bits assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, null, 16, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, null, 16, DataBuffer.TYPE_INT) ); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, lut, 16, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, lut, 16, DataBuffer.TYPE_INT) ); }
@Test public void testCreatePacked8() { // "BYTE 332 RGB" assertEquals( createPacked(sRGB, 0xe0, 0x1c, 0x03, 0x0, DataBuffer.TYPE_BYTE, false), ImageTypeSpecifiers.createPacked(sRGB, 0xe0, 0x1c, 0x3, 0x0, DataBuffer.TYPE_BYTE, false) ); // "BYTE 2222 ARGB" assertEquals( createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, false), ImageTypeSpecifiers.createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, false) ); // "BYTE 2222 ARGB PRE" assertEquals( createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, true), ImageTypeSpecifiers.createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, true) ); // Extra: Make sure color models bits is actually 8 (ImageTypeSpecifiers equivalent returns 32) assertEquals(8, ImageTypeSpecifiers.createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, false).getColorModel().getPixelSize()); }
@Test public void testCreateFromIndexedColorModel1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { int[] colors = createIntLut(1 << bits); IndexColorModel colorModel = new IndexColorModel(bits, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(colorModel), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); } }
@Test public void testCreateIndexedByteArrays16() { for (int bits = 1; bits <= 8; bits <<= 1) { byte[] lut = createByteLut(1 << bits); byte[] lut = createByteLut(1 << 16); // This is stupid, but ImageTypeSpecifier enforces lut.length == 1 << bits
@Test public void testCreatePacked8() { // "BYTE 332 RGB" assertEquals( createPacked(sRGB, 0xe0, 0x1c, 0x03, 0x0, DataBuffer.TYPE_BYTE, false), ImageTypeSpecifiers.createPacked(sRGB, 0xe0, 0x1c, 0x3, 0x0, DataBuffer.TYPE_BYTE, false) ); // "BYTE 2222 ARGB" assertEquals( createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, false), ImageTypeSpecifiers.createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, false) ); // "BYTE 2222 ARGB PRE" assertEquals( createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, true), ImageTypeSpecifiers.createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, true) ); // Extra: Make sure color models bits is actually 8 (ImageTypeSpecifiers equivalent returns 32) assertEquals(8, ImageTypeSpecifiers.createPacked(sRGB, 0xc0, 0x30, 0x0c, 0x03, DataBuffer.TYPE_BYTE, false).getColorModel().getPixelSize()); }
@Test public void testCreateIndexedIntArray16() { int[] colors = createIntLut(1 << 16); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT)), ImageTypeSpecifiers.createIndexed(colors, false, -1, 16, DataBuffer.TYPE_USHORT) ); }
@Test public void testCreateIndexedByteArrays1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { byte[] lut = createByteLut(1 << bits); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_BYTE), ImageTypeSpecifiers.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_BYTE) ); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_BYTE), ImageTypeSpecifiers.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_BYTE) ); } }
@Test public void testCreatePacked16() { // TYPE_USHORT_555_RGB assertEquals( createPacked(sRGB, DCM_555_RED_MASK, DCM_555_GRN_MASK, DCM_555_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false), ImageTypeSpecifiers.createPacked(sRGB, DCM_555_RED_MASK, DCM_555_GRN_MASK, DCM_555_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false) ); // "SHORT 555 RGB" (impossible, only BYTE, USHORT, INT supported) // TYPE_USHORT_565_RGB assertEquals( createPacked(sRGB, DCM_565_RED_MASK, DCM_565_GRN_MASK, DCM_565_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false), ImageTypeSpecifiers.createPacked(sRGB, DCM_565_RED_MASK, DCM_565_GRN_MASK, DCM_565_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false) ); // "USHORT 4444 ARGB" assertEquals( createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, false), ImageTypeSpecifiers.createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, false) ); // "USHORT 4444 ARGB PRE" assertEquals( createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, true), ImageTypeSpecifiers.createPacked(sRGB, 0xf00, 0xf0, 0xf, 0xf000, DataBuffer.TYPE_USHORT, true) ); // Extra: Make sure color models bits is actually 16 (ImageTypeSpecifier equivalent returns 32) assertEquals(16, ImageTypeSpecifiers.createPacked(sRGB, DCM_565_RED_MASK, DCM_565_GRN_MASK, DCM_565_BLU_MASK, 0, DataBuffer.TYPE_USHORT, false).getColorModel().getPixelSize()); }
@Test public void testCreateDiscreteAlphaIndexedFromIndexColorModel8() { int[] colors = createIntLut(1 << 8); IndexColorModel colorModel = new IndexColorModel(8, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE); assertEquals( new ImageTypeSpecifier(colorModel, colorModel.createCompatibleSampleModel(1, 1)), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); }
@Test public void testCreateIndexedByteArrays32() { for (int bits = 1; bits <= 8; bits <<= 1) { byte[] lut = createByteLut(1 << bits); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, null, bits, DataBuffer.TYPE_INT) ); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, lut, bits, DataBuffer.TYPE_INT) ); } byte[] lut = createByteLut(1 << 16); // This is stupid, but ImageTypeSpecifier enforces lut.length == 1 << bits assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, null, 16, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, null, 16, DataBuffer.TYPE_INT) ); assertEquals( ImageTypeSpecifier.createIndexed(lut, lut, lut, lut, 16, DataBuffer.TYPE_INT), ImageTypeSpecifiers.createIndexed(lut, lut, lut, lut, 16, DataBuffer.TYPE_INT) ); }
@Test public void testCreateDiscreteAlphaIndexedFromIndexColorModel16() { int[] colors = createIntLut(1 << 16); IndexColorModel colorModel = new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT); assertEquals( new ImageTypeSpecifier(colorModel, colorModel.createCompatibleSampleModel(1, 1)), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); }
@Test public void testCreateIndexedByteArrays16() { for (int bits = 1; bits <= 8; bits <<= 1) { byte[] lut = createByteLut(1 << bits); byte[] lut = createByteLut(1 << 16); // This is stupid, but ImageTypeSpecifier enforces lut.length == 1 << bits
@Test public void testCreateIndexedIntArray1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { int[] colors = createIntLut(1 << bits); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(bits, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE)), ImageTypeSpecifiers.createIndexed(colors, false, -1, bits, DataBuffer.TYPE_BYTE) ); } }
@Test public void testCreateFromIndexedColorModel16() { int[] colors = createIntLut(1 << 16); IndexColorModel colorModel = new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(colorModel), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); }
@Test public void testCreateIndexedIntArray16() { int[] colors = createIntLut(1 << 16); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(new IndexColorModel(16, colors.length, colors, 0, false, -1, DataBuffer.TYPE_USHORT)), ImageTypeSpecifiers.createIndexed(colors, false, -1, 16, DataBuffer.TYPE_USHORT) ); }
@Test public void testCreateFromIndexedColorModel1to8() { for (int bits = 1; bits <= 8; bits <<= 1) { int[] colors = createIntLut(1 << bits); IndexColorModel colorModel = new IndexColorModel(bits, colors.length, colors, 0, false, -1, DataBuffer.TYPE_BYTE); assertEquals( IndexedImageTypeSpecifier.createFromIndexColorModel(colorModel), ImageTypeSpecifiers.createFromIndexColorModel(colorModel) ); } }