Here you can find the source of cropImage(BufferedImage image, int x1, int y1, int x2, int y2)
Parameter | Description |
---|---|
image | image to crop |
x1 | top left x coordinate |
y1 | top left y coordinate |
x2 | bottom right x coordinate |
y2 | bottom right y coordinate |
public static BufferedImage cropImage(BufferedImage image, int x1, int y1, int x2, int y2)
//package com.java2s; /**//from w w w . ja va 2s . c o m * Copyright 2010 Neuroph Project http://neuroph.sourceforge.net * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ import java.awt.image.BufferedImage; public class Main { /** * Crops (returns subimage) of specified input image at specified points. * * @param image image to crop * @param x1 top left x coordinate * @param y1 top left y coordinate * @param x2 bottom right x coordinate * @param y2 bottom right y coordinate * * @return image croped at specified points */ public static BufferedImage cropImage(BufferedImage image, int x1, int y1, int x2, int y2) { return image.getSubimage(x1, y1, x2 - x1, y2 - y1); } }