List of utility methods to do Image Create
JPanel | createImagePanel(Image image, Color backColor) create Image Panel JPanel panel = new JPanel(); panel.add(new JLabel(new ImageIcon(image))); if (backColor != null) { panel.setBackground(backColor); return panel; |
Image | getImage(Class> clazz, String path) get Image return getIcon(clazz, path).getImage();
|
Image | getImage(Component component) Get the screen image from the component RepaintManager repaintManager = RepaintManager.currentManager(component); double w = component.getWidth(); double h = component.getHeight(); if ((w == 0) || (h == 0)) { return null; BufferedImage image = new BufferedImage((int) w, (int) h, BufferedImage.TYPE_INT_ARGB); repaintManager.setDoubleBufferingEnabled(false); ... |
BufferedImage | getImage(Component component) get Image if (component == null) { return null; int width = component.getWidth(); int height = component.getHeight(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); component.paintAll(g); ... |
BufferedImage | getImage(File imageFile) get Image BufferedImage al = null; try { String imageFileName = imageFile.getName(); String imageFormat = imageFileName.substring(imageFileName.lastIndexOf('.') + 1); Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(imageFormat); ImageReader reader = readers.next(); if (reader == null) { JOptionPane.showConfirmDialog(null, ... |
BufferedImage | getImage(final int width, final int height) Creates an image of specified dimension, filled with the background color. return getImage(width, height, getColorBackground());
|
Image | getImage(final String name) get Image final ImageIcon icon = images.get(name); if (icon == null) { try { final ImageIcon image = new ImageIcon(ImageIO.read(new File(name))); images.put(name, image); return image.getImage(); } catch (Exception e) { return null; ... |
Image | getImage(ImageIcon imageIcon) get Image return imageIcon != null ? imageIcon.getImage() : null;
|
BufferedImage | getImage(JComponent component) draw the component as an image BufferedImage ret = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = ret.getGraphics(); component.paint(g); g.dispose(); return ret; |
Image | getImage(Object obj, String filePath) get Image URL url = obj.getClass().getResource(filePath);
return getImage(url);
|