ps.println("Band " + band + ":"); for (int j = raster.getMinY(); j < (raster.getMinY() + raster.getHeight()); j++) { for (int i = raster.getMinX(); i < (raster.getMinX() + raster.getWidth()); i++) { if (raster.getTransferType() == DataBuffer.TYPE_DOUBLE) ps.print(raster.getSampleDouble(i, j, band)); ps.print(raster.getSampleFloat(i, j, band)); else ps.print(raster.getSample(i, j, band)); if (i < (raster.getMinX() + raster.getWidth() - 1)) { ps.print(" ");
private Raster clipRowToRect(final Raster raster, final Rectangle rect, final int[] bands, final int xSub) { if (rect.contains(raster.getMinX(), 0, raster.getWidth(), 1) && xSub == 1 && bands == null /* TODO: Compare bands with that of raster */) { return raster; } return raster.createChild(rect.x / xSub, 0, rect.width / xSub, 1, 0, 0, bands); }
private Raster clipRowToRect(final Raster raster, final Rectangle rect, final int[] bands, final int xSub) { if (rect.contains(raster.getMinX(), 0, raster.getWidth(), 1) && xSub == 1 && bands == null /* TODO: Compare bands with that of raster */) { return raster; } return raster.createChild(rect.x / xSub, 0, rect.width / xSub, 1, 0, 0, bands); }
private Raster clipRowToRect(final Raster raster, final Rectangle rect, final int[] bands, final int xSub) { if (rect.contains(raster.getMinX(), 0, raster.getWidth(), 1) && xSub == 1 && bands == null /* TODO: Compare bands with that of raster */) { return raster; } return raster.createChild(rect.x / xSub, 0, rect.width / xSub, 1, 0, 0, bands); }
private Raster clipRowToRect(final Raster raster, final Rectangle rect, final int[] bands, final int xSub) { if (rect.contains(raster.getMinX(), 0, raster.getWidth(), 1) && xSub == 1 && bands == null /* TODO: Compare bands with that of raster */) { return raster; } return raster.createChild(rect.x / xSub, 0, rect.width / xSub, 1, 0, 0, bands); }
private Raster clipRowToRect(final Raster raster, final Rectangle rect, final int[] bands, final int xSub) { if (rect.contains(raster.getMinX(), 0, raster.getWidth(), 1) && xSub == 1 && bands == null /* TODO: Compare bands with that of raster */) { return raster; } return raster.createChild(rect.x / xSub, 0, rect.width / xSub, 1, 0, 0, bands); }
private Raster clipRowToRect(final Raster raster, final Rectangle rect, final int[] bands, final int xSub) { if (rect.contains(raster.getMinX(), 0, raster.getWidth(), 1) && xSub == 1 && bands == null /* TODO: Compare bands with that of raster */) { return raster; } return raster.createChild((rect.x + xSub - 1) / xSub, 0, (rect.width + xSub - 1) / xSub, 1, 0, 0, bands); }
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int width = min(src.getWidth(), dstIn.getWidth()); // We always work in RGB, using DataBuffer.TYPE_INT transfer type. int[] srcData = null; int[] dstData = null; int[] resData = new int[width - src.getMinX()]; for (int y = src.getMinY(); y < src.getHeight(); y++) { srcData = (int[]) src.getDataElements(src.getMinX(), y, width, 1, srcData); dstData = (int[]) dstIn.getDataElements(src.getMinX(), y, width, 1, dstData); for (int x = src.getMinX(); x < width; x++) { // TODO: Decide how to handle alpha (if at all) resData[x] = 0xff000000 | ((~srcData[x] ^ dstData[x])) & 0xffffff; } dstOut.setDataElements(src.getMinX(), y, width, 1, resData); } } };
/** * Constructs multi-dimensional grid envelope defined by a {@link Raster}. The two first * dimensions are set to the [{@linkplain Raster#getMinX x} .. x+{@linkplain Raster#getWidth * width}-1] and [{@linkplain Raster#getMinY y} .. y+{@linkplain Raster#getHeight height}-1] * inclusive ranges respectively. Extra dimensions (if any) are set to the [0..0] inclusive * range. * * <p>Notice that this method ensure interoperability between {@link Raster} dimensions in * Java2D style and {@link GridEnvelope} dimensions in ISO 19123 style providing that the user * remember to add 1 to the {@link GridEnvelope#getHigh(int)} values. * * @param raster The raster for which to construct a grid envelope. * @param dimension Number of dimensions for this grid envelope. Must be equals or greater than * 2. */ public GeneralGridEnvelope(final Raster raster, final int dimension) { this(raster.getMinX(), raster.getMinY(), raster.getWidth(), raster.getHeight(), dimension); }
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int width = min(src.getWidth(), dstIn.getWidth()); // We always work in RGB, using DataBuffer.TYPE_INT transfer type. int[] srcData = null; int[] dstData = null; int[] resData = new int[width - src.getMinX()]; for (int y = src.getMinY(); y < src.getHeight(); y++) { srcData = (int[]) src.getDataElements(src.getMinX(), y, width, 1, srcData); dstData = (int[]) dstIn.getDataElements(src.getMinX(), y, width, 1, dstData); for (int x = src.getMinX(); x < width; x++) { int sAlpha = (srcData[x] >>> 24) & 0xFF; int sRed = sAlpha * ((srcData[x] >> 16) & 0xFF) / 0xFF; int sGreen = sAlpha * ((srcData[x] >> 8) & 0xFF) / 0xFF; int sBlue = sAlpha * ((srcData[x]) & 0xFF) / 0xFF; int dAlpha = (dstData[x] >>> 24) & 0xFF; int dRed = dAlpha * ((dstData[x] >> 16) & 0xFF) / 0xFF; int dGreen = dAlpha * ((dstData[x] >> 8) & 0xFF) / 0xFF; int dBlue = dAlpha * ((dstData[x]) & 0xFF) / 0xFF; resData[x] = (max(sAlpha, dAlpha) << 24) | (max(sRed, dRed) << 16) | (max(sGreen, dGreen) << 8) | (max(sBlue, dBlue)); } dstOut.setDataElements(src.getMinX(), y, width, 1, resData); } } };
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int width = min(src.getWidth(), dstIn.getWidth()); // We always work in RGB, using DataBuffer.TYPE_INT transfer type. int[] srcData = null; int[] dstData = null; int[] resData = new int[width - src.getMinX()]; for (int y = src.getMinY(); y < src.getHeight(); y++) { srcData = (int[]) src.getDataElements(src.getMinX(), y, width, 1, srcData); dstData = (int[]) dstIn.getDataElements(src.getMinX(), y, width, 1, dstData); for (int x = src.getMinX(); x < width; x++) { int sAlpha = (srcData[x] >>> 24) & 0xFF; int sRed = sAlpha * ((srcData[x] >> 16) & 0xFF) / 0xFF; int sGreen = sAlpha * ((srcData[x] >> 8) & 0xFF) / 0xFF; int sBlue = sAlpha * ((srcData[x]) & 0xFF) / 0xFF; int dAlpha = (dstData[x] >>> 24) & 0xFF; int dRed = dAlpha * ((dstData[x] >> 16) & 0xFF) / 0xFF; int dGreen = dAlpha * ((dstData[x] >> 8) & 0xFF) / 0xFF; int dBlue = dAlpha * ((dstData[x]) & 0xFF) / 0xFF; resData[x] = (min(sAlpha, dAlpha) << 24) | (min(sRed, dRed) << 16) | (min(sGreen, dGreen) << 8) | (min(sBlue, dBlue)); } dstOut.setDataElements(src.getMinX(), y, width, 1, resData); } } };
public WritableRaster createCompatibleDestRaster(Raster src) { return icm.createCompatibleWritableRaster(src.getWidth(), src.getHeight()) .createWritableTranslatedChild(src.getMinX(), src.getMinY()); }
int minx = r.getMinX(); int miny = r.getMinY(); int maxx = minx + r.getWidth();
int minx = r.getMinX(); int miny = r.getMinY(); int maxx = minx + r.getWidth();
srcTile.getMinX(), srcTile.getMinY(), srcTile.getWidth(),
srcTile.getMinX(), srcTile.getMinY(), srcTile.getWidth(),
final boolean sourceHasAlpha = sourceColorModel.hasAlpha(); final int alphaBand = sourceHasAlpha ? numBands - 1 : -1; final int minx = sourceRaster.getMinX(); final int maxx = minx + w; final int miny = sourceRaster.getMinY();
Raster srcChannel = clippedRow.createChild(clippedRow.getMinX(), 0, clippedRow.getWidth(), 1, 0, 0, new int[] {c});
for (int c = 0; c < header.getChannels(); c++) { WritableRaster destChannel = destRaster.createWritableChild(destRaster.getMinX(), destRaster.getMinY(), destRaster.getWidth(), destRaster.getHeight(), 0, 0, new int[] {c}); Raster srcChannel = clippedRow.createChild(clippedRow.getMinX(), 0, clippedRow.getWidth(), 1, 0, 0, new int[] {c});