List of usage examples for java.awt.image WritableRaster getBounds
public Rectangle getBounds()
From source file:GraphicsUtil.java
public static void copyBand(Raster src, int srcBand, WritableRaster dst, int dstBand) { Rectangle sR = src.getBounds(); Rectangle dR = dst.getBounds(); Rectangle cpR = sR.intersection(dR); copyBand(src, cpR, srcBand, dst, cpR, dstBand); }
From source file:GraphicsUtil.java
public static void copyBand(Raster src, Rectangle sR, int sBand, WritableRaster dst, Rectangle dR, int dBand) { int dy = dR.y - sR.y; int dx = dR.x - sR.x; sR = sR.intersection(src.getBounds()); dR = dR.intersection(dst.getBounds()); int width, height; if (dR.width < sR.width) width = dR.width;/*from ww w . j av a 2s . c om*/ else width = sR.width; if (dR.height < sR.height) height = dR.height; else height = sR.height; int x = sR.x + dx; int[] samples = null; for (int y = sR.y; y < sR.y + height; y++) { samples = src.getSamples(sR.x, y, width, 1, sBand, samples); dst.setSamples(x, y + dy, width, 1, dBand, samples); } }