protected final int checkCoordinatesAndComputeIndex(final int x, final int y, final int i) {
        if (x < 0 || x >= width || y < 0 || y >= height) {
            throw new IllegalArgumentException("Coordinates out of range (" + x + ", " + y + ")");
        }
        if (i < 0 || i >= samplesPerPixel) {
            throw new IllegalArgumentException("Sample index out of range, value " + i + " where valid range is (0," + (samplesPerPixel - 1) + ")");
        }
        return y * width + x + i * planarOffset;
    }
Constructs an instance allocating memory for the specified dimensions.

@param width           a value of 1 or greater
@param height          a value of 1 or greater
@param samplesPerPixel a value of 1 or greater
src/main/java/org/apache/commons/imaging/formats/tiff/AbstractTiffRasterData.java