private static boolean isWhiteZero(byte[] r, byte[] g, byte[] b) { return bilevelColorValue(r, g, b, 0xff, 0); }
private static boolean bilevelColorValue(byte[] r, byte[] g, byte[] b, int blackValue, int whiteValue) { return rgbIsValueAt(r, g, b, (byte) blackValue, 0) && rgbIsValueAt(r, g, b, (byte) whiteValue, 1); }
static ImageType getTypeFromRGB(int mapSize, byte[] r, byte[] g, byte[] b, int dataTypeSize, int numBands) { if (numBands == 1) { if (dataTypeSize == 1) { // Bilevel image if (mapSize != 2) { throw new IllegalArgumentException(PropertyUtil.getString("TIFFImageEncoder7")); } if (isBlackZero(r, g, b)) { return BILEVEL_BLACK_IS_ZERO; } else if (isWhiteZero(r, g, b)) { return BILEVEL_WHITE_IS_ZERO; } } return PALETTE; } return UNSUPPORTED; }
indexColorModel.getBlues(b); builder.imageType = ImageType.getTypeFromRGB(colormapSize, r, g, b, dataTypeSize, numBands); if (builder.imageType == ImageType.PALETTE) { builder.imageType = ImageType.getTypeFromColorSpace(colorSpace, params); builder.numExtraSamples = getNumberOfExtraSamplesForColorSpace(colorSpace, builder.imageType, numBands);
new TIFFField(TIFFImageDecoder.TIFF_PHOTOMETRIC_INTERPRETATION, TIFFField.TIFF_SHORT, 1, new char[] {(char) imageInfo.getType().getPhotometricInterpretation()}));
private static boolean isBlackZero(byte[] r, byte[] g, byte[] b) { return bilevelColorValue(r, g, b, 0, 0xff); }