图像切割(按指定起点坐标和宽高切割)，填充满整个图片（直径取长宽最小值）

@param srcImage 源图像
@param x 原图的x坐标起始位置
@param y 原图的y坐标起始位置
@return {@link BufferedImage}
@since 4.1.15
552632
public static BufferedImage cut(Image srcImage, int x, int y) {
		return cut(srcImage, x, y, -1);
	}
1437
public BufferedImage getBufferedImage(int width, int height) {
        // using the new approach of Java 2D API
        BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = (Graphics2D) buf.getGraphics();
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g2d.drawImage(image, 0, 0, width, height, null);
        g2d.dispose();
        return (buf);
    }
444116
public int getUnsignedPixelValue(BufferedImage image, int x, int y) {
		short pixelValue = getPixelValue(image, x, y);
		int unsignedPixelValue = getUnsignedPixelValue(pixelValue);
		return unsignedPixelValue;
	}
404893
static BufferedImage gaussianBlur(BufferedImage src, BufferedImage dst, int radius) {
        int width  = src.getWidth();
        int height = src.getHeight();

        if (dst == null || dst.getWidth() != width || dst.getHeight() != height || src.getType() != dst.getType()) {
            dst = createColorModelCompatibleImage(src);
        }

        float[] kernel = createGaussianKernel(radius);

        if (src.getType() == BufferedImage.TYPE_INT_ARGB) {
            int[] srcPixels = new int[width * height];
            int[] dstPixels = new int[width * height];

            getPixels(src, 0, 0, width, height, srcPixels);

            // horizontal pass
            blur(srcPixels, dstPixels, width, height, kernel, radius);

            // vertical pass
            // noinspection SuspiciousNameCombination
            blur(dstPixels, srcPixels, height, width, kernel, radius);

            // the result is now stored in srcPixels due to the 2nd pass
            setPixels(dst, 0, 0, width, height, srcPixels);
        } else if (src.getType() == BufferedImage.TYPE_BYTE_GRAY) {
            byte[] srcPixels = new byte[width * height];
            byte[] dstPixels = new byte[width * height];

            getPixels(src, 0, 0, width, height, srcPixels);

            // horizontal pass
            blur(srcPixels, dstPixels, width, height, kernel, radius);

            // vertical pass
            // noinspection SuspiciousNameCombination
            blur(dstPixels, srcPixels, height, width, kernel, radius);

            // the result is now stored in srcPixels due to the 2nd pass
            setPixels(dst, 0, 0, width, height, srcPixels);
        } else {
            throw new IllegalArgumentException("EffectUtils.gaussianBlur() src image is not a supported type, type=[" + src.getType()
                                               + "]");
        }

        return dst;
    }
590604
public static boolean isTransparent(BufferedImage image, int x, int y) {
		int pixel = image.getRGB(x, y);
		boolean transparent = (pixel >> 24) == 0x00;
		return transparent;
	}
97960
private void createImageBuffer() throws JavaAVException {
		int format = pixelFormat.value();
		int width = avContext.width();
		int height = avContext.height();

		picture = new AVPicture();

		if (avpicture_alloc(picture, format, width, height) < 0)
			throw new JavaAVException("Could not allocate picture.");
	}
1027541
private BufferedImage convertImage(BufferedImage image)
    {
        if (image.getType() == BufferedImage.TYPE_INT_RGB)
        {
            return image;
        }
        else
        {
            BufferedImage newImage = new BufferedImage(image.getWidth(),
                                                       image.getHeight(),
                                                       BufferedImage.TYPE_INT_RGB);
            newImage.getGraphics().drawImage(image, 0, 0, null);
            return newImage;
        }
    }
113962
public static BufferedImage roate90(BufferedImage src) {
		int width = src.getWidth();
		int height = src.getHeight();

		BufferedImage bRotate = new BufferedImage(height, width, src.getType());
		for (int x = 0; x < width; x++)
			for (int y = 0; y < height; y++)
				bRotate.setRGB(height - 1 - y, x, src.getRGB(x, y));
		return bRotate;
	}
112193
public static BufferedImage copy(BufferedImage image) {
        BufferedImage newImage = new BufferedImage(image.getWidth(), image.getHeight(),
            image.getType());
        return copy(image, newImage);
    }
1371464
public static BufferedImage createBufferedImage(int width, int height,
			String imageFormat) {

		int imageType;

		switch (imageFormat.toLowerCase()) {
		case IMAGE_FORMAT_JPG:
		case IMAGE_FORMAT_JPEG:
			imageType = BufferedImage.TYPE_INT_RGB;
			break;
		default:
			imageType = BufferedImage.TYPE_INT_ARGB;
		}

		BufferedImage image = new BufferedImage(width, height, imageType);

		return image;
	}
1165567
public static Graphics2D createGraphics(BufferedImage image, Color color) {
		return GraphicsUtil.createGraphics(image, color);
	}
678530
private void process(int x,int y)
    {
        int A = getSourcePixel(x-1,y-1);
        int B = getSourcePixel(x,y-1);
        int C = getSourcePixel(x+1,y-1);
        int D = getSourcePixel(x-1,y);
        int E = getSourcePixel(x,y);
        int F = getSourcePixel(x+1,y);
        int G = getSourcePixel(x-1,y+1);
        int H = getSourcePixel(x,y+1);
        int I = getSourcePixel(x+1,y+1);
        int E0 = E;
        int E1 = E;
        int E2 = E;
        int E3 = E;
        int E4 = E;
        int E5 = E;
        int E6 = E;
        int E7 = E;
        int E8 = E;
        
        if (different(B,H) && different(D,F)) {
            E0 = !different(D,B) ? D : E;
            E1 = ((!different(D,B)) && different(E,C)) || ((!different(B,F)) && different(E,A)) ? B : E;
            E2 = !different(B,F) ? F : E;
            E3 = ((!different(D,B)) && different(E,G)) || ((!different(D,H)) && different(E,A)) ? D : E;
            E4 = E;
            E5 = ((!different(B,F)) && different(E,I)) || ((!different(H,F)) && different(E,C)) ? F : E;
            E6 = !different(D,H) ? D : E;
            E7 = ((!different(D,H)) && different(E,I)) || ((!different(H,F)) && different(E,G)) ? H : E;
            E8 = !different(H,F) ? F : E;
        }
        
        setDestPixel((x*3),(y*3),E0);
        setDestPixel((x*3)+1,(y*3),E1);
        setDestPixel((x*3)+2,(y*3),E2);
        setDestPixel((x*3),(y*3)+1,E3);
        setDestPixel((x*3)+1,(y*3)+1,E4);
        setDestPixel((x*3)+2,(y*3)+1,E5);
        setDestPixel((x*3),(y*3)+2,E6);
        setDestPixel((x*3)+1,(y*3)+2,E7);
        setDestPixel((x*3)+2,(y*3)+2,E8);
    }
1220509
public ImageHandlerBuilder crop(int x, int y, int width, int height) {
         height = Math.min(height, image.getHeight() - y); 
         width = Math.min(width, image.getWidth() - x);

         BufferedImage crop = Scalr.crop(image, x, y, width, height);
         image.flush();// cannot throw
         image = crop;
         return this;
     }
1021050
public Img cut(int x, int y, int radius) {
		final BufferedImage srcImage = getValidSrcImg();
		final int width = srcImage.getWidth();
		final int height = srcImage.getHeight();

		// 计算直径
		final int diameter = radius > 0 ? radius * 2 : Math.min(width, height);
		final BufferedImage targetImage = new BufferedImage(diameter, diameter, BufferedImage.TYPE_INT_ARGB);
		final Graphics2D g = targetImage.createGraphics();
		g.setClip(new Ellipse2D.Double(0, 0, diameter, diameter));

		if (this.positionBaseCentre) {
			x = x - width / 2 + diameter / 2;
			y = y - height / 2 + diameter / 2;
		}
		g.drawImage(srcImage, x, y, null);
		g.dispose();
		this.targetImage = targetImage;
		return this;
	}
864266
public BufferedImage getBufferedImage(int width, int height) {
		BufferedImage bi = chart.createBufferedImage(width, height);
		return bi;
	}
230022
public void setRGB(final BufferedImage IMAGE, final int X, final int Y, final int WIDTH, final int HEIGHT, final int[] PIXELS) {
        int type = IMAGE.getType();
        if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) {
            IMAGE.getRaster().setDataElements(X, Y, WIDTH, HEIGHT, PIXELS);
        } else {
            IMAGE.setRGB(X, Y, WIDTH, HEIGHT, PIXELS, 0, WIDTH);
        }
    }
254136
public void drawImage(Image image, float x, float y, Color col) {
		predraw();
		image.draw(x, y, col);
		currentColor.bind();
		postdraw();
	}