Java Utililty Methods Image Create

List of utility methods to do Image Create

Description

The list of methods to do Image Create are organized into topic(s).

Method

ImagecreateImage(byte[] data)
create Image
return new ImageIcon(data).getImage();
BufferedImagecreateImage(Component comp, Icon icon)
create Image
return createImage(comp, icon, null);
BufferedImagecreateImage(Icon icon)
Returns an image got by drawing an Icon.
int w = icon.getIconWidth();
int h = icon.getIconHeight();
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
Color color = g2.getColor();
Composite compos = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
g2.setColor(new Color(1f, 1f, 1f, 0f));
...
BufferedImagecreateImage(JPanel panel)
Crea una imagen del contenido de un JPanel
int w = panel.getWidth();
int h = panel.getHeight();
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
panel.paint(g);
return bi;
IconcreateImage(String str)
create Image
final int ICON_DIMENSION = 16;
final Color BG_COLOR = new Color(96, 224, 96);
if (str.length() > 1)
    return null;
BufferedImage image = new BufferedImage(ICON_DIMENSION, ICON_DIMENSION, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setComposite(AlphaComposite.Src);
graphics.setColor(new Color(0, 0, 0, 0));
...
ImagecreateImage(URL url, String description, boolean checkPresence)
create Image
return createImageIcon(url, description, null, null).getImage();
BufferedImagecreateImageCopy(Image image)
create Image Copy
return createImageCopy(image, false);
ImageIconcreateImageFromBase64String(String s)
create Image From Base String
return null;
BufferedImagecreateImageFromInvisibleComponent(JComponent component)
create Image From Invisible Component
Dimension componentSize = component.getPreferredSize();
component.setDoubleBuffered(false);
component.setSize(componentSize);
component.addNotify();
component.validate();
BufferedImage img = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
        .getDefaultConfiguration().createCompatibleImage(component.getWidth(), component.getHeight());
Graphics2D grap = img.createGraphics();
...
BufferedImagecreateImageFromVisibleComponent(JComponent comp, int cw, int ch)
create Image From Visible Component
BufferedImage retImage = null;
if (comp == null)
    return retImage;
try {
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = genv.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    java.awt.image.ColorModel cm = gc.getColorModel();
...