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

App下載
首頁javaimageJava Graphics - 如何縮放BufferedImage(Image)

Java Graphics - 如何縮放BufferedImage(Image)

我們想知道如何縮放BufferedImage(Image)。
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class Main {
  public static void main(String[] args) throws IOException {

    final int SCALE = 2;

    Image img = new ImageIcon(new URL("http://www.yjpub.cn/style/download.png")).getImage();

    BufferedImage bi = new BufferedImage(SCALE * img.getWidth(null), SCALE
        * img.getHeight(null), BufferedImage.TYPE_INT_ARGB);

    Graphics2D grph = (Graphics2D) bi.getGraphics();
    grph.scale(SCALE, SCALE);

    grph.drawImage(img, 0, 0, null);
    grph.dispose();

    ImageIO.write(bi, "png", new File("double_size.png"));
  }
}