Java BufferedImage Subimage getSubimage(BufferedImage image, int x, int y, int w, int h)

Here you can find the source of getSubimage(BufferedImage image, int x, int y, int w, int h)

Description

get Subimage

License

Open Source License

Declaration

public static BufferedImage getSubimage(BufferedImage image, int x, int y, int w, int h) 

Method Source Code


//package com.java2s;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;

public class Main {
    public static BufferedImage getSubimage(BufferedImage image, int x, int y, int w, int h) {
        BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = newImage.createGraphics();
        g.drawRenderedImage(image, AffineTransform.getTranslateInstance(-x, -y));
        g.dispose();/*w  ww.  j av  a  2  s .  co  m*/
        return newImage;
    }
}

Related

  1. getSubImage(BufferedImage image, int x, int y, int w, int h)
  2. getSubimage(BufferedImage image, int x, int y, int width, int height)
  3. getSubImage(BufferedImage image, int x, int y, int width, int height)
  4. getSubimage(BufferedImage image, int x, int y, int width, int height)
  5. getSubImage(BufferedImage img, int x, int y, int w, int h)