Java BufferedImage Operation generateBufferedImageFromComponent(Component component)

Here you can find the source of generateBufferedImageFromComponent(Component component)

Description

Erstellt Image aus einer (Java)Komponente

License

Apache License

Parameter

Parameter Description
component Javakomponente aus der die Bilddatei erstellt werden soll

Return

Image der Komponente

Declaration

public static BufferedImage generateBufferedImageFromComponent(Component component) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.Component;
import java.awt.Graphics;

import java.awt.image.BufferedImage;

public class Main {
    /**//w  w  w. j  a  v a2s .  c  o  m
     * Erstellt Image aus einer (Java)Komponente
     * 
     * @param component
     *            Javakomponente aus der die Bilddatei erstellt werden soll
     * 
     * @return Image der Komponente
     */
    public static BufferedImage generateBufferedImageFromComponent(Component component) {
        BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(),
                BufferedImage.TYPE_INT_RGB);
        Graphics g = image.getGraphics();
        g.setColor(component.getBackground());
        g.fillRect(0, 0, image.getWidth(), image.getHeight());
        component.print(g);
        g.dispose();
        return image;
    }
}

Related

  1. floodFill(BufferedImage img, int startX, int startY, Color targetColor, Color replacementColor)
  2. fuzzyCompare(final BufferedImage img1, final BufferedImage img2, final double colorTolerance, final double pixelTolerance, final int fuzzyBlockDimension)
  3. fuzzyEquals(BufferedImage a, BufferedImage b, int threshold)
  4. genBlackAndWhiteImage(BufferedImage image)
  5. generate(int w, int h, BufferedImage img)
  6. generateImageHash(BufferedImage image)
  7. generateOutline(BufferedImage source, Color color, boolean alpha)
  8. gradientMask(BufferedImage img, float start, float stop)
  9. greyScale(BufferedImage image)