public RenderedImage createScaledRendering(int w, int h, RenderingHints hints) { float sX = w/getWidth(); float sY = h/getHeight(); float scale = Math.min(sX, sY); AffineTransform at = AffineTransform.getScaleInstance(scale, scale); RenderContext rc = new RenderContext(at, hints); float dX = (getWidth()*scale)-w; float dY = (getHeight()*scale)-h; RenderedImage ri = createRendering(rc); CachableRed cr = RenderedImageCachableRed.wrap(ri); return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h), PadMode.ZERO_PAD, null); }
/** * Construct A Rendered Pad operation. If the pad is smaller than * the original image size then this devolves to a Crop. * * @param src The image to pad/crop * @param bounds The bounds of the result (same coord system as src). * @param padMode The pad mode to use (currently ignored). * @param hints The hints to use for drawing 'pad' area. */ public PadRed(CachableRed src, Rectangle bounds, PadMode padMode, RenderingHints hints) { super(src,bounds,src.getColorModel(), fixSampleModel(src, bounds), bounds.x, bounds.y, null); this.padMode = padMode; if (DEBUG) { System.out.println("Src: " + src + " Bounds: " + bounds + " Off: " + src.getTileGridXOffset() + ", " + src.getTileGridYOffset()); } this.hints = hints; }
public WritableRaster copyData(WritableRaster wr) { // Get my source. CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds(); if (wrR.intersects(srcR)) { Rectangle r = wrR.intersection(srcR); // Limit the raster I send to my source to his rect. WritableRaster srcWR; srcWR = wr.createWritableChild(r.x, r.y, r.width, r.height, r.x, r.y, null); src.copyData(srcWR); } if (padMode == PadMode.ZERO_PAD) { handleZero(wr); } else if (padMode == PadMode.REPLICATE) { handleReplicate(wr); } else if (padMode == PadMode.WRAP) { handleWrap(wr); } return wr; }
protected void handleZero(WritableRaster wr) { CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds();
protected void handleWrap(WritableRaster wr) { handleZero(wr); }
protected void handleZero(WritableRaster wr) { CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds();
protected void handleWrap(WritableRaster wr) { handleZero(wr); }
public RenderedImage createScaledRendering(int w, int h, RenderingHints hints) { float sX = w/getWidth(); float sY = h/getHeight(); float scale = Math.min(sX, sY); AffineTransform at = AffineTransform.getScaleInstance(scale, scale); RenderContext rc = new RenderContext(at, hints); float dX = (getWidth()*scale)-w; float dY = (getHeight()*scale)-h; RenderedImage ri = createRendering(rc); CachableRed cr = RenderedImageCachableRed.wrap(ri); return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h), PadMode.ZERO_PAD, null); }
public WritableRaster copyData(WritableRaster wr) { // Get my source. CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds(); if (wrR.intersects(srcR)) { Rectangle r = wrR.intersection(srcR); // Limit the raster I send to my source to his rect. WritableRaster srcWR; srcWR = wr.createWritableChild(r.x, r.y, r.width, r.height, r.x, r.y, null); src.copyData(srcWR); } if (padMode == PadMode.ZERO_PAD) { handleZero(wr); } else if (padMode == PadMode.REPLICATE) { handleReplicate(wr); } else if (padMode == PadMode.WRAP) { handleWrap(wr); } return wr; }
protected void handleZero(WritableRaster wr) { CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds();
protected void handleWrap(WritableRaster wr) { handleZero(wr); }
/** * Construct A Rendered Pad operation. If the pad is smaller than * the original image size then this devolves to a Crop. * * @param src The image to pad/crop * @param bounds The bounds of the result (same coord system as src). * @param padMode The pad mode to use (currently ignored). * @param hints The hints to use for drawing 'pad' area. */ public PadRed(CachableRed src, Rectangle bounds, PadMode padMode, RenderingHints hints) { super(src,bounds,src.getColorModel(), fixSampleModel(src, bounds), bounds.x, bounds.y, null); this.padMode = padMode; if (DEBUG) { System.out.println("Src: " + src + " Bounds: " + bounds + " Off: " + src.getTileGridXOffset() + ", " + src.getTileGridYOffset()); } this.hints = hints; }
public RenderedImage createScaledRendering(int w, int h, RenderingHints hints) { float sX = w/getWidth(); float sY = h/getHeight(); float scale = Math.min(sX, sY); AffineTransform at = AffineTransform.getScaleInstance(scale, scale); RenderContext rc = new RenderContext(at, hints); float dX = (getWidth()*scale)-w; float dY = (getHeight()*scale)-h; RenderedImage ri = createRendering(rc); CachableRed cr = RenderedImageCachableRed.wrap(ri); return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h), PadMode.ZERO_PAD, null); }
public WritableRaster copyData(WritableRaster wr) { // Get my source. CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds(); if (wrR.intersects(srcR)) { Rectangle r = wrR.intersection(srcR); // Limit the raster I send to my source to his rect. WritableRaster srcWR; srcWR = wr.createWritableChild(r.x, r.y, r.width, r.height, r.x, r.y, null); src.copyData(srcWR); } if (padMode == PadMode.ZERO_PAD) { handleZero(wr); } else if (padMode == PadMode.REPLICATE) { handleReplicate(wr); } else if (padMode == PadMode.WRAP) { handleWrap(wr); } return wr; }
protected void handleReplicate(WritableRaster wr) { CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds();
/** * Construct A Rendered Pad operation. If the pad is smaller than * the original image size then this devolves to a Crop. * * @param src The image to pad/crop * @param bounds The bounds of the result (same coord system as src). * @param padMode The pad mode to use (currently ignored). * @param hints The hints to use for drawing 'pad' area. */ public PadRed(CachableRed src, Rectangle bounds, PadMode padMode, RenderingHints hints) { super(src,bounds,src.getColorModel(), fixSampleModel(src, bounds), bounds.x, bounds.y, null); this.padMode = padMode; if (DEBUG) { System.out.println("Src: " + src + " Bounds: " + bounds + " Off: " + src.getTileGridXOffset() + ", " + src.getTileGridYOffset()); } this.hints = hints; }
(r.width != myBounds.width) || (r.height != myBounds.height)) cr = new PadRed(cr, myBounds, PadMode.ZERO_PAD, null); vec.add(cr);
protected void handleReplicate(WritableRaster wr) { CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds();
(r.width != myBounds.width) || (r.height != myBounds.height)) cr = new PadRed(cr, myBounds, PadMode.ZERO_PAD, null); vec.add(cr);
protected void handleReplicate(WritableRaster wr) { CachableRed src = (CachableRed)getSources().get(0); Rectangle srcR = src.getBounds(); Rectangle wrR = wr.getBounds();