List of usage examples for java.awt.image Raster createCompatibleWritableRaster
public WritableRaster createCompatibleWritableRaster(int w, int h)
From source file:CheckAlignmentOpImage.java
public Raster computeTile(int x, int y) { Raster r1 = source1.getTile(x, y); Raster r2 = source2.getTile(x, y); int xBounds = r1.getWidth(); if (r2.getWidth() < xBounds) xBounds = r2.getWidth();/* ww w . ja v a2 s . co m*/ int yBounds = r1.getHeight(); if (r2.getHeight() < yBounds) yBounds = r2.getHeight(); WritableRaster wr; wr = r1.createCompatibleWritableRaster(xBounds, yBounds); int tmpi; int tmpj; for (int i = 0; i < wr.getWidth(); i++) for (int j = 0; j < wr.getHeight(); j++) { tmpi = i / samplingPeriod; tmpj = j / samplingPeriod; if ((tmpi % 2 == 0) && (tmpj % 2 == 0)) wr.setDataElements(i, j, r2.getDataElements(i, j, null)); else if ((tmpi % 2 != 0) && (tmpj % 2 != 0)) wr.setDataElements(i, j, r2.getDataElements(i, j, null)); else wr.setDataElements(i, j, r1.getDataElements(i, j, null)); } return wr; }