/** * Assigns a constant rectangle to the input Gray8Image, replacing values in the image. * * @param image the input image (output replaces input). * @throws Error if the input is not a Gray8Image. */ public void push(Image image) throws Error { if (!(image instanceof Gray8Image)) { throw new Error( Error.PACKAGE.ALGORITHM, ErrorCodes.IMAGE_NOT_GRAY8IMAGE, image.toString(), null, null); } Gray8Image input = (Gray8Image) image; byte[] data = input.getData(); int nLimitY = Math.min(input.getHeight(), this.cY + this.nHeight); int nLimitX = Math.min(input.getWidth(), this.cX + this.nWidth); for (int i = this.cY; i < nLimitY; i++) { int nStart = i * image.getWidth(); for (int j = this.cX; j < nLimitX; j++) { data[nStart + j] = this.bValue; } } super.setOutput(input); }