protected CachableRed convertSourceCS(RenderedImage ri) { return convertSourceCS(GraphicsUtil.wrap(ri)); } }
protected Graphics2D createGraphics(BufferedImage bi) { return GraphicsUtil.createGraphics(bi); }
public WritableRaster copyData(WritableRaster wr) { GraphicsUtil.copyData(theTile, wr); return wr; }
/** * Draws <code>ri</code> into <code>g2d</code>. It does this be * requesting tiles from <code>ri</code> and drawing them individually * in <code>g2d</code> it also takes care of some colorspace and alpha * issues. * @param g2d The Graphics2D to draw into. * @param ri The image to be drawn. */ public static void drawImage(Graphics2D g2d, RenderedImage ri) { drawImage(g2d, wrap(ri)); }
protected CachableRed convertSourceCS(CachableRed cr) { if (csLinear) return GraphicsUtil.convertToLsRGB(cr); else return GraphicsUtil.convertTosRGB(cr); }
/** * Coerces data within a bufferedImage to match newAlphaPreMult, * Note that this can not change the colormodel of bi so you * * @param wr The raster to change the state of. * @param cm The colormodel currently associated with data in wr. * @param newAlphaPreMult The desired state of alpha Premult for raster. * @return A new colormodel that matches newAlphaPreMult. */ public static ColorModel coerceData(WritableRaster wr, ColorModel cm, boolean newAlphaPreMult) { // System.out.println("CoerceData: " + cm.isAlphaPremultiplied() + // " Out: " + newAlphaPreMult); if ( ! cm.hasAlpha() ) // Nothing to do no alpha channel return cm; if (cm.isAlphaPremultiplied() == newAlphaPreMult) // nothing to do alpha state matches... return cm; // System.out.println("CoerceData: " + wr.getSampleModel()); if (newAlphaPreMult) { multiplyAlpha(wr); } else { divideAlpha(wr); } return coerceColorModel(cm, newAlphaPreMult); }
cm.isAlphaPremultiplied(), null); Graphics2D g2d = GraphicsUtil.createGraphics(bi); g2d.translate(-r.x, -r.y); GraphicsUtil.coerceData(wr, cr.getColorModel(), cm.isAlphaPremultiplied()); first = false; } else { GraphicsUtil.drawImage(g2d, cr);
protected CachableRed renderGNR() { AffineTransform at, rcAT; at = usr2dev; rcAT = new AffineTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), 0, 0); RenderContext rc = new RenderContext(rcAT, null, renderingHints); RenderedImage ri = rootFilter.createRendering(rc); if (ri == null) return null; CachableRed ret; ret = GraphicsUtil.wrap(ri); ret = setupCache(ret); int dx = Math.round((float)at.getTranslateX()); int dy = Math.round((float)at.getTranslateY()); ret = new TranslateRed(ret, ret.getMinX()+dx, ret.getMinY()+dy); ret = GraphicsUtil.convertTosRGB(ret); return ret; }
cr = GraphicsUtil.wrap(ri); cr = GraphicsUtil.convertToLsRGB(cr);
ColorModel g2dCM = getDestinationColorModel(g2d); ColorSpace g2dCS = null; if (g2dCM != null) cr = convertTosRGB(cr); else if (g2dCS == ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)) cr = convertToLsRGB(cr); Rectangle gcR = getDestinationBounds(g2d);
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { ColorModel dstPreCM = dstCM; if (!dstCM.isAlphaPremultiplied()) dstPreCM = GraphicsUtil.coerceData((WritableRaster)dstIn, dstCM, true); precompose(src, dstIn, dstOut); if (!dstCM.isAlphaPremultiplied()) { GraphicsUtil.coerceData(dstOut, dstPreCM, false); if (dstIn != dstOut) GraphicsUtil.coerceData((WritableRaster)dstIn, dstPreCM, false); } }
src = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); GraphicsUtil.copyData(origSrc, src); srcCMPre = GraphicsUtil.coerceColorModel(srcCM, true); GraphicsUtil.copyData(origSrc, src); dstCMPre = GraphicsUtil.coerceColorModel(dstCM, true); (src.isAlphaPremultiplied() != origSrc.isAlphaPremultiplied())) { GraphicsUtil.copyData(src, origSrc); (dest.isAlphaPremultiplied() != finalDest.isAlphaPremultiplied())){ GraphicsUtil.copyData(dest, finalDest);
ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d); if ((g2dCS == null) || (g2dCS != crCS)) { return false; GraphicsUtil.drawImage(g2d, (Filter)i.next());
/** * Paints this node without applying Filter, Mask, Composite and clip. * * @param g2d the Graphics2D to use */ public void primitivePaint(Graphics2D g2d) { if (image == null) return; GraphicsUtil.drawImage(g2d, image); }
protected static ColorModel fixColorModel(CachableRed src) { ColorModel cm = src.getColorModel(); if (cm.hasAlpha()) { if (!cm.isAlphaPremultiplied()) cm = GraphicsUtil.coerceColorModel(cm, true); return cm; } int b = src.getSampleModel().getNumBands()+1; if (b > 4) throw new IllegalArgumentException ("CompositeRed can only handle up to three band images"); int [] masks = new int[4]; for (int i=0; i < b-1; i++) masks[i] = 0xFF0000 >> (8*i); masks[3] = 0xFF << (8*(b-1)); ColorSpace cs = cm.getColorSpace(); return new DirectColorModel(cs, 8*b, masks[0], masks[1], masks[2], masks[3], true, DataBuffer.TYPE_INT); } }
return false; ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d); if ((g2dCS == null) || (g2dCS != ColorSpace.getInstance(ColorSpace.CS_sRGB))){
cm.isAlphaPremultiplied(), null); Graphics2D g2d = GraphicsUtil.createGraphics(bi); g2d.translate(-r.x, -r.y); GraphicsUtil.coerceData(wr, cr.getColorModel(), cm.isAlphaPremultiplied()); first = false; } else { GraphicsUtil.drawImage(g2d, cr);
/** * Draws <code>ri</code> into <code>g2d</code>. It does this be * requesting tiles from <code>ri</code> and drawing them individually * in <code>g2d</code> it also takes care of some colorspace and alpha * issues. * @param g2d The Graphics2D to draw into. * @param ri The image to be drawn. */ public static void drawImage(Graphics2D g2d, RenderedImage ri) { drawImage(g2d, wrap(ri)); }
protected CachableRed renderGNR() { AffineTransform at, rcAT; at = usr2dev; rcAT = new AffineTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), 0, 0); RenderContext rc = new RenderContext(rcAT, null, renderingHints); RenderedImage ri = rootFilter.createRendering(rc); if (ri == null) return null; CachableRed ret; ret = GraphicsUtil.wrap(ri); ret = setupCache(ret); int dx = Math.round((float)at.getTranslateX()); int dy = Math.round((float)at.getTranslateY()); ret = new TranslateRed(ret, ret.getMinX()+dx, ret.getMinY()+dy); ret = GraphicsUtil.convertTosRGB(ret); return ret; }
cr = GraphicsUtil.wrap(ri); cr = GraphicsUtil.convertToLsRGB(cr);