// Create the tile using the ancestor SampleModel.
tiles[tileX - minTileX][tileY - minTileY] =
createWritableRaster(ancestorSampleModel,
new Point(tileXToX(tileX),
tileYToY(tileY)));
WritableRaster tile = tiles[tileX - minTileX][tileY - minTileY];
// If a source is available try to set the tile's data.
if(src != null) {
// Get the bounds of the tile's support.
Rectangle tileRect = getTileRect(tileX, tileY);
// Determine the intersection of the tile and the overlap.
Rectangle rect = overlapBounds.intersection(tileRect);
// Bail if this doesn't intersect the effective overlap.
if(rect.isEmpty()) {
return;
}
// If a source ROI is present, use it.
if(srcROI != null) {
// Attempt to get the ROI as a Shape.
Shape roiShape = srcROI.getAsShape();
if (roiShape != null) {
// Determine the area of overlap.
Area a = new Area(rect);
a.intersect(new Area(roiShape));
if(!a.isEmpty()) {
// If the area is non-empty overlay the pixels.
overlayPixels(tile, src, a);
}
} else {
int[][] bitmask =
srcROI.getAsBitmask(rect.x, rect.y,
rect.width, rect.height,
null);
overlayPixels(tile, src, rect, bitmask);
}
} else {
// If the intersection equals the tile area, copy data into
// the entire tile. If the tile straddles the edge of the
// source, copy only into the intersection.
if(!rect.isEmpty()) {
if(bandList == null && rect.equals(tileRect)) {
// The current image has the same bands in the
// same order as its ancestor TiledImage and
// the requested tile is completely within "src".
if (tileRect.equals(tile.getBounds()))
src.copyData(tile);
else
src.copyData(
tile.createWritableChild(rect.x, rect.y,
rect.width,
rect.height,
rect.x,
rect.y,
null));