/** * Clamp to the minimal size of the given values. * * @param dstSize * e.g. getWidth() or getHeight() of the destination raster. * @param dstOrdinate * e.g srcX, srcY, the location to put the data in destination raster. * @param srcSize * e.g. getWidth() or getHeight() of the source raster. * * @param srcOrdinate * e.g dstX, dstY, the location to read the data from the source raster. * @param copySize * e.g. width/height of rectangle to put data in this raster. * @return the minimal value */ protected static final int clampSize( int dstSize, int dstOrdinate, int srcSize, int srcOrdinate, int copySize ) { return min( dstSize - dstOrdinate, srcSize - srcOrdinate, copySize ); }