List of usage examples for java.awt.image ColorModel coerceData
public ColorModel coerceData(WritableRaster raster, boolean isAlphaPremultiplied)
From source file:GraphicsUtil.java
/** * Create a new ColorModel with it's alpha premultiplied state matching * newAlphaPreMult./* w ww . j av a2 s . co m*/ * @param cm The ColorModel to change the alpha premult state of. * @param newAlphaPreMult The new state of alpha premult. * @return A new colorModel that has isAlphaPremultiplied() * equal to newAlphaPreMult. */ public static ColorModel coerceColorModel(ColorModel cm, boolean newAlphaPreMult) { if (cm.isAlphaPremultiplied() == newAlphaPreMult) return cm; // Easiest way to build proper colormodel for new Alpha state... // Eventually this should switch on known ColorModel types and // only fall back on this hack when the CM type is unknown. WritableRaster wr = cm.createCompatibleWritableRaster(1, 1); return cm.coerceData(wr, newAlphaPreMult); }