Java BufferedImage Crop croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY)

Here you can find the source of croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY)

Description

cropped Copy

License

Apache License

Declaration

public static BufferedImage croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics2D;
import java.awt.Rectangle;

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY) {
        int width = endX - startX;
        int height = endY - startY;
        BufferedImage cropped = new BufferedImage(width, height, image.getType());
        Graphics2D graphics2d = cropped.createGraphics();
        graphics2d.drawImage(image, 0, 0, width, height, startX, startY, endX, endY, null);
        graphics2d.dispose();//  www . j  a va  2  s  .c o m
        return cropped;
    }

    public static BufferedImage croppedCopy(BufferedImage championRow, Rectangle rect) {
        return croppedCopy(championRow, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
    }
}

Related

  1. cropImage(BufferedImage image, int x1, int y1, int x2, int y2)
  2. cropImage(BufferedImage src, int x, int y, int w, int h)
  3. cropImage(BufferedImage src, int x, int y, int w, int h)
  4. cropImage(final BufferedImage img, int x, int y, int w, int h, double xScale, double yScale)
  5. cropImageRelative(BufferedImage image, double leftCropFactor, double rightCropFactor, double topCropFactor, double bottomCropFactor)
  6. cropScale(BufferedImage source, int width, int height)
  7. cropToAspectRatio(BufferedImage image, float aspect)
  8. cropToBeSameSize(BufferedImage image1, BufferedImage image2)
  9. divideImage(BufferedImage bi, int rows, int cols, int width, int height)