private void checkBounds(final int x, final int y, final int w, final int h) {
        if (w <= 0) {
            throw new RasterFormatException("negative or zero subimage width");
        }
        if (h <= 0) {
            throw new RasterFormatException("negative or zero subimage height");
        }
        if (x < 0 || x >= width) {
            throw new RasterFormatException("subimage x is outside raster");
        }
        if (x + w > width) {
            throw new RasterFormatException("subimage (x+width) is outside raster");
        }
        if (y < 0 || y >= height) {
            throw new RasterFormatException("subimage y is outside raster");
        }
        if (y + h > height) {
            throw new RasterFormatException("subimage (y+height) is outside raster");
        }
    }
Performs a check on the specified sub-region to verify that it is within the constraints of the ImageBuilder bounds.

@param x the X coordinate of the upper-left corner of the specified rectangular region
@param y the Y coordinate of the upper-left corner of the specified rectangular region
@param w the width of the specified rectangular region
@param h the height of the specified rectangular region
@throws RasterFormatException if width or height are equal or less than zero, or if the subimage is outside raster (on x or y axis)
src/main/java/org/apache/commons/imaging/common/ImageBuilder.java