Here you can find the source of getBufferedImage(Component comp, BufferedImage image)
Parameter | Description |
---|---|
comp | komponen sumber |
image | gambar target |
public static void getBufferedImage(Component comp, BufferedImage image)
//package com.java2s; /*// w w w . java 2 s. co m * Copyright (c) 2011, StripBandunk and/or its affiliates. All rights reserved. * * http://stripbandunk.com/ * * STRIPBANDUNK PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.awt.Component; import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { /** * Mendapatkan BufferedImage dari sebuah komponen * @param comp komponen sumber * @param image gambar target */ public static void getBufferedImage(Component comp, BufferedImage image) { // Mendapatkan Graphics2D dari image Graphics2D g2 = image.createGraphics(); // menggambar seluruh komponen comp.paint(g2); // menghilangkan Graphics2D g2.dispose(); } /** * Mendapatkan gambar dari sebuah komponen * @param comp komponen sumber * @return gambar BufferedImage */ public static BufferedImage getBufferedImage(Component comp) { // Membuat gambar BufferedImage BufferedImage image = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_ARGB); // menggambar dengan memanggil metode getBufferedImageFromComponent(); getBufferedImage(comp, image); // menggembalikan gambar return image; } }