@Override protected void computeRect(Raster[] sources, WritableRaster dest, Rectangle destRect) { synchronized (this) { if (transform == null) { int lcms_intent = intent.getValue() < 4 ? intent.getValue() : LCMS.INTENT_RELATIVE_COLORIMETRIC; int lcms_proofIntent = proofIntent.getValue() < 4 ? proofIntent.getValue() : LCMS.INTENT_RELATIVE_COLORIMETRIC; int lcms_flags = intent.getValue() == 4 || proofIntent.getValue() == 4 ? LCMS.cmsFLAGS_BLACKPOINTCOMPENSATION : 0; ColorSpace sourceCS = source.getColorModel().getColorSpace(); LCMS.Profile sourceProfile = sourceCS instanceof LCMS_ColorSpace ? ((LCMS_ColorSpace) sourceCS).getProfile() : new LCMS.Profile(((ICC_ColorSpace) sourceCS).getProfile()); ColorSpace targetCS = targetColorModel.getColorSpace(); LCMS.Profile targetProfile = targetCS instanceof LCMS_ColorSpace ? ((LCMS_ColorSpace) targetCS).getProfile() : new LCMS.Profile(((ICC_ColorSpace) targetCS).getProfile()); LCMS.Profile proofProfile = proof != null ? new LCMS.Profile(proof) : null; int inType = mapLCMSType(sourceCS.getType(), source.getColorModel().getTransferType()); int outType = mapLCMSType(targetCS.getType(), colorModel.getTransferType()); transform = proofProfile != null ? new LCMS.Transform( sourceProfile, inType, targetProfile, outType, proofProfile, lcms_proofIntent, lcms_intent, lcms_flags) : new LCMS.Transform( sourceProfile, inType, targetProfile, outType, lcms_intent, lcms_flags); } } RasterFormatTag[] formatTags = getFormatTags(); Rectangle srcRect = mapDestRect(destRect, 0); RasterAccessor src = new RasterAccessor(sources[0], srcRect, formatTags[0], getSourceImage(0).getColorModel()); RasterAccessor dst = new RasterAccessor(dest, destRect, formatTags[1], this.getColorModel()); if (src.getDataType() == dst.getDataType()) { transform.doTransform( src, formatTags[0], getSourceImage(0).getColorModel(), dst, formatTags[1], this.getColorModel()); } else { throw new IllegalArgumentException("Input and output rasters don't match!"); } }