Here you can find the source of getSubImage(BufferedImage srcImage, int x, int y, int factorWidth, int factorHeight)
Parameter | Description |
---|---|
srcImage | the image to get sub image from |
x | the X coordinate of the upper-left corner of the specified rectangular region |
y | the Y coordinate of the upper-left corner of the specified rectangular region |
factorWidth | the width of the specified rectangular region |
factorHeight | the height of the specified rectangular region |
public static BufferedImage getSubImage(BufferedImage srcImage, int x, int y, int factorWidth, int factorHeight)
//package com.java2s; //License from project: LGPL import java.awt.image.BufferedImage; public class Main { /**//from ww w.j a va 2 s . c o m * Gets the sub image from original image by specified X,Y coords and Width and Height. * * @param srcImage * the image to get sub image from * @param x * the X coordinate of the upper-left corner of the specified rectangular region * @param y * the Y coordinate of the upper-left corner of the specified rectangular region * @param factorWidth * the width of the specified rectangular region * @param factorHeight * the height of the specified rectangular region * @return sub-image from original image */ public static BufferedImage getSubImage(BufferedImage srcImage, int x, int y, int factorWidth, int factorHeight) { if (factorWidth < srcImage.getWidth() && factorHeight < srcImage.getHeight()) { return srcImage.getSubimage(x, y, factorWidth, factorHeight); } return srcImage; } }