/** * Given a one band (plus eventual alpha) color model and the red part of a gray color returns * the appropriate background color to be used in the mosaic operation * * @param red * @param cm */ double mapToGrayColor(Color gray, ComponentColorModel cm) { double[] rescaleFactors = new double[DataBuffer.TYPE_UNDEFINED + 1]; rescaleFactors[DataBuffer.TYPE_BYTE] = 1; rescaleFactors[DataBuffer.TYPE_SHORT] = 255; rescaleFactors[DataBuffer.TYPE_INT] = Integer.MAX_VALUE / 255; rescaleFactors[DataBuffer.TYPE_USHORT] = 512; rescaleFactors[DataBuffer.TYPE_DOUBLE] = 1 / 255.0; rescaleFactors[DataBuffer.TYPE_FLOAT] = 1 / 255.0; rescaleFactors[DataBuffer.TYPE_UNDEFINED] = 1; return gray.getRed() / rescaleFactors[cm.getTransferType()]; }
if ((ccm.getTransferType() == DataBuffer.TYPE_DOUBLE || ccm.getTransferType() == DataBuffer.TYPE_FLOAT || ccm.getTransferType() == DataBuffer.TYPE_UNDEFINED || !hasAlpha)) {
Transparency.OPAQUE, ccm.getTransferType()); ccm.getTransferType()); } else if (colorModel instanceof DirectColorModel) { final DirectColorModel dcm = (DirectColorModel) colorModel;
ComponentColorModel.OPAQUE, ccm.getTransferType()); else return new ComponentColorModel(cs, ccm.hasAlpha(), ccm .isAlphaPremultiplied(), ccm.getTransparency(), ccm .getTransferType()); } else if (old_cm instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) old_cm;
&& colorSpaceIsOk && defCCM.getTransparency() == actualCCM.getTransparency() && defCCM .getTransferType() == actualCCM.getTransferType());
|| (ccm.getTransferType() == DataBuffer.TYPE_DOUBLE || ccm.getTransferType() == DataBuffer.TYPE_FLOAT || ccm.getTransferType() == DataBuffer.TYPE_UNDEFINED)) {