public static ImageTypeSpecifier createIndexed(final int[] colors, final boolean hasAlpha, final int transIndex, final int bits, final int dataType) { return createFromIndexColorModel(new IndexColorModel(bits, colors.length, colors, 0, hasAlpha, transIndex, dataType)); }
@Override public ImageTypeSpecifier getRawImageType(int imageIndex) throws IOException { IconResource resource = readIconResource(imageIndex); switch (resource.depth()) { case 1: return ImageTypeSpecifiers.createFromIndexColorModel(ICNS1BitColorModel.INSTANCE); case 4: return ImageTypeSpecifiers.createFromIndexColorModel(ICNS4BitColorModel.INSTANCE); case 8: return ImageTypeSpecifiers.createFromIndexColorModel(ICNS8BitColorModel.INSTANCE); case 32: if (resource.isCompressed()) { return ImageTypeSpecifiers.createBanded( ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[]{0, 1, 2, 3}, createBandOffsets(resource.size().width * resource.size().height), DataBuffer.TYPE_BYTE, true, false ); } else { return ImageTypeSpecifiers.createInterleaved( ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[]{1, 2, 3, 0}, DataBuffer.TYPE_BYTE, true, false ); } default: throw new IllegalStateException(String.format("Unknown bit depth: %d", resource.depth())); } }
return ImageTypeSpecifiers.createFromIndexColorModel(header.getEGAPalette()); case 8: if (channels == 1) { return ImageTypeSpecifiers.createFromIndexColorModel(palette);
@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) ); }
if (colorMap != null) { IndexColorModel cm = colorMap.getIndexColorModel(header, isEHB()); specifier = ImageTypeSpecifiers.createFromIndexColorModel(cm); break;
@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) ); } }
specifier = ImageTypeSpecifiers.createFromIndexColorModel(indexed.createColorModel()); break; case 16:
@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 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) ); }
case TGA.IMAGETYPE_COLORMAPPED_HUFFMAN: case TGA.IMAGETYPE_COLORMAPPED_HUFFMAN_QUADTREE: return ImageTypeSpecifiers.createFromIndexColorModel(header.getColorMap()); case TGA.IMAGETYPE_MONOCHROME: case TGA.IMAGETYPE_MONOCHROME_RLE:
return ImageTypeSpecifiers.createFromIndexColorModel(metadata.colorData.getIndexColorModel());
case 4: case 8: return ImageTypeSpecifiers.createFromIndexColorModel(readColorMap());
return ImageTypeSpecifiers.createFromIndexColorModel(icm);
public static ImageTypeSpecifier createIndexed(final int[] colors, final boolean hasAlpha, final int transIndex, final int bits, final int dataType) { return createFromIndexColorModel(new IndexColorModel(bits, colors.length, colors, 0, hasAlpha, transIndex, dataType)); }
return ImageTypeSpecifiers.createFromIndexColorModel(header.getEGAPalette()); case 8: if (channels == 1) { return ImageTypeSpecifiers.createFromIndexColorModel(palette);
@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 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) ); } }
specifier = ImageTypeSpecifiers.createFromIndexColorModel(indexed.createColorModel()); break; case 16:
@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 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) ); }