国产gaysexchina男同gay,japanrcep老熟妇乱子伦视频,吃奶呻吟打开双腿做受动态图,成人色网站,国产av一区二区三区最新精品

App下載
首頁javaimageJava Graphics - 如何使用subImage(Rectangle)方法創(chuàng)建較小的圖像

Java Graphics - 如何使用subImage(Rectangle)方法創(chuàng)建較小的圖像

我們想知道如何使用subImage(Rectangle)方法創(chuàng)建較小的圖像。
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

public class Main {

  public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    BufferedImage image = robot.createScreenCapture(new Rectangle(d));
    BufferedImage sub = image.getSubimage(0, 0, 400, 400);
    File f = new File("SubImage.png");
    ImageIO.write(sub, "png", f);
    final ImageIcon im = new ImageIcon(f.toURI().toURL());

    Runnable r = new Runnable() {

      @Override
      public void run() {
        JOptionPane.showMessageDialog(null, new JLabel(im));
      }
    };
    SwingUtilities.invokeLater(r);
  }
}