// Path: ImagingKit_Core/src/main/java/hageldave/imagingkit/core/util/ImagingKitUtils.java
// public final class ImagingKitUtils {
// 
// 	// not to be instantiated
// 	private ImagingKitUtils() {}
// 
// 
// 	/**
// 	 * Clamps a value to the range [0,255].
// 	 * Returns 0 for values less than 0, 255 for values greater than 255, 
// 	 * and the value it self when in range.
// 	 * @param val value to be clamped
// 	 * @return value clamped to [0,255]
// 	 */
// 	public static final int clamp_0_255(int val){
// 		return Math.max(0, Math.min(val, 255));
// 	}
// 
// 	/**
// 	 * Clamps a value to the range [0.0, 1.0].
// 	 * Returns 0.0 for values less than 0, 1.0 for values greater than 1.0, 
// 	 * and the value it self when in range.
// 	 * @param val value to be clamped
// 	 * @return value clamped to [0.0, 1.0]
// 	 */
// 	public static double clamp_0_1(double val){
// 		return Math.max(0.0, Math.min(val, 1.0));
// 	}
// 	
// 	/**
// 	 * Throws an {@link IllegalArgumentException} when the specified area 
// 	 * is not within the bounds of the specified image, or if the area
// 	 * is not positive.
// 	 * This is used for parameter evaluation.
// 	 * 
// 	 * @param xStart left boundary of the area
// 	 * @param yStart top boundary of the area
// 	 * @param width of the area
// 	 * @param height of the area
// 	 * @param img the area has to fit in.
// 	 * @throws IllegalArgumentException when area not in image bounds or not area not positive
// 	 */
// 	public static void requireAreaInImageBounds(final int xStart, final int yStart, final int width, final int height, ImgBase<?> img){
// 		if(		width <= 0 || height <= 0 ||
// 				xStart < 0 || yStart < 0 ||
// 				xStart+width > img.getWidth() || yStart+height > img.getHeight() )
// 		{
// 			throw new IllegalArgumentException(String.format(
// 							"provided area [%d,%d][%d,%d] is not within bounds of the image [%d,%d]",
// 							xStart,yStart,width,height, img.getWidth(), img.getHeight()));
// 		}
// 	}
// 
// }


import java.util.Spliterator;
import java.util.function.Consumer;
import hageldave.imagingkit.core.util.ImagingKitUtils;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.DirectColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.util.Arrays;
	 * @since 1.0
	 */
	public Pixel getPixel(int x, int y){
		return new Pixel(this, x,y);
	}

	/**
	 * Copies specified area of this Img to the specified destination Img
	 * at specified destination coordinates. If destination Img is null a new
	 * Img with the areas size will be created and the destination coordinates
	 * will be ignored so that the Img will contain all the values of the area.
	 * <p>
	 * The specified area has to be within the bounds of this image or
	 * otherwise an IllegalArgumentException will be thrown. Only the
	 * intersecting part of the area and the destination image is copied which
	 * allows for an out of bounds destination area origin.
	 *
	 * @param x area origin in this image (x-coordinate)
	 * @param y area origin in this image (y-coordinate)
	 * @param w width of area
	 * @param h height of area
	 * @param dest destination Img
	 * @param destX area origin in destination Img (x-coordinate)
	 * @param destY area origin in destination Img (y-coordinate)
	 * @return the destination Img
	 * @throws IllegalArgumentException if the specified area is not within
	 * the bounds of this Img or if the size of the area is not positive.
	 * @since 1.0
	 */
	public Img copyArea(int x, int y, int w, int h, Img dest, int destX, int destY){
// Path: ImagingKit_Core/src/main/java/hageldave/imagingkit/core/util/ImagingKitUtils.java
// public final class ImagingKitUtils {
// 
// 	// not to be instantiated
// 	private ImagingKitUtils() {}
// 
// 
// 	/**
// 	 * Clamps a value to the range [0,255].
// 	 * Returns 0 for values less than 0, 255 for values greater than 255, 
// 	 * and the value it self when in range.
// 	 * @param val value to be clamped
// 	 * @return value clamped to [0,255]
// 	 */
// 	public static final int clamp_0_255(int val){
// 		return Math.max(0, Math.min(val, 255));
// 	}
// 
// 	/**
// 	 * Clamps a value to the range [0.0, 1.0].
// 	 * Returns 0.0 for values less than 0, 1.0 for values greater than 1.0, 
// 	 * and the value it self when in range.
// 	 * @param val value to be clamped
// 	 * @return value clamped to [0.0, 1.0]
// 	 */
// 	public static double clamp_0_1(double val){
// 		return Math.max(0.0, Math.min(val, 1.0));
// 	}
// 	
// 	/**
// 	 * Throws an {@link IllegalArgumentException} when the specified area 
// 	 * is not within the bounds of the specified image, or if the area
// 	 * is not positive.
// 	 * This is used for parameter evaluation.
// 	 * 
// 	 * @param xStart left boundary of the area
// 	 * @param yStart top boundary of the area
// 	 * @param width of the area
// 	 * @param height of the area
// 	 * @param img the area has to fit in.
// 	 * @throws IllegalArgumentException when area not in image bounds or not area not positive
// 	 */
// 	public static void requireAreaInImageBounds(final int xStart, final int yStart, final int width, final int height, ImgBase<?> img){
// 		if(		width <= 0 || height <= 0 ||
// 				xStart < 0 || yStart < 0 ||
// 				xStart+width > img.getWidth() || yStart+height > img.getHeight() )
// 		{
// 			throw new IllegalArgumentException(String.format(
// 							"provided area [%d,%d][%d,%d] is not within bounds of the image [%d,%d]",
// 							xStart,yStart,width,height, img.getWidth(), img.getHeight()));
// 		}
// 	}
// 
// }


// Path: ImagingKit_Core/src/main/java/hageldave/imagingkit/core/Img.java
import java.util.Spliterator;
import java.util.function.Consumer;
import hageldave.imagingkit.core.util.ImagingKitUtils;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.DirectColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.util.Arrays;

	 * @since 1.0
	 */
	public Pixel getPixel(int x, int y){
		return new Pixel(this, x,y);
	}

	/**
	 * Copies specified area of this Img to the specified destination Img
	 * at specified destination coordinates. If destination Img is null a new
	 * Img with the areas size will be created and the destination coordinates
	 * will be ignored so that the Img will contain all the values of the area.
	 * <p>
	 * The specified area has to be within the bounds of this image or
	 * otherwise an IllegalArgumentException will be thrown. Only the
	 * intersecting part of the area and the destination image is copied which
	 * allows for an out of bounds destination area origin.
	 *
	 * @param x area origin in this image (x-coordinate)
	 * @param y area origin in this image (y-coordinate)
	 * @param w width of area
	 * @param h height of area
	 * @param dest destination Img
	 * @param destX area origin in destination Img (x-coordinate)
	 * @param destY area origin in destination Img (y-coordinate)
	 * @return the destination Img
	 * @throws IllegalArgumentException if the specified area is not within
	 * the bounds of this Img or if the size of the area is not positive.
	 * @since 1.0
	 */
	public Img copyArea(int x, int y, int w, int h, Img dest, int destX, int destY){
		ImagingKitUtils.requireAreaInImageBounds(x, y, w, h, this);