private static BufferedImage readImage(final ImageIcon imageIcon) { final Image tmpImage = imageIcon.getImage(); final BufferedImage image = new BufferedImage(imageIcon.getIconWidth(), imageIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); image.getGraphics().drawImage(tmpImage, 0, 0, null); tmpImage.flush(); return image; }
image = new ImageIcon(image).getImage(); type = BufferedImage.TYPE_INT_ARGB; bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); g.drawImage(image, 0, 0, null); g.dispose(); return bimage;
public static void main(String[] args) throws Exception { double framerate = 12.0; double transitionDuration = 1; // seconds double slideDuration = 3; // seconds File photoDir = new File(args[0]); File[] files = photoDir.listFiles(new FilenameFilter(){ public boolean accept(File dir, String name) { if(StringUtils.goLowerCase(name).endsWith("jpg")) return true; return false; } }); int numFrames = (int)(files.length * framerate * (slideDuration + transitionDuration) + (transitionDuration * framerate)); MJPEGGenerator m = new MJPEGGenerator(new File(args[1]), 640, 480, framerate, numFrames); for(int i = 0; i < files.length; i++) { System.out.println("processing file "+i); ImageIcon ii = new ImageIcon(files[i].getCanonicalPath()); m.addImage(ii.getImage()); } m.finishAVI(); }
System.err.println("Error loading system tray library, system tray support disabled."); splash = new ImageIcon(getClass().getClassLoader().getResource("splash.gif")); splashLabel = new JLabel("", splash, JLabel.CENTER); onIcon = new ImageIcon(getClass().getClassLoader().getResource("openfire_on-16x16.gif")); offIcon = new ImageIcon(getClass().getClassLoader().getResource("openfire_off-16x16.gif")); frame.setIconImage(offIcon.getImage()); trayIcon = new TrayIcon(offIcon.getImage(), appName, menu); trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.pack();
_logMonitorFrame = new JFrame("LogFactor5"); _logMonitorFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); _logMonitorFrame.setIconImage(new ImageIcon(lf5IconURL).getImage()); _logMonitorFrame.getContentPane().add(splitPane, BorderLayout.CENTER); _logMonitorFrame.getContentPane().add(createToolBar(), BorderLayout.NORTH); _logMonitorFrame.getContentPane().add(createStatusArea(), BorderLayout.SOUTH);
public BufferedImage loadImage(String url) { ImageIcon icon = new ImageIcon(url); Image image = icon.getImage(); // Create empty BufferedImage, sized to Image BufferedImage buffImage = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); // Draw Image into BufferedImage Graphics g = buffImage.getGraphics(); g.drawImage(image, 0, 0, null); return buffImage; }
private Icon createDisabledIcon() { if(defaultIcon instanceof ImageIcon) { Image i = GrayFilter.createDisabledImage(((ImageIcon) defaultIcon).getImage()); return new ImageIcon(i); } else { BufferedImage bi = new BufferedImage(defaultIcon.getIconWidth(), defaultIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); g.setColor(new Color(0, 0, 0, 0)); g.fillRect(0, 0, defaultIcon.getIconWidth(), defaultIcon.getIconHeight()); defaultIcon.paintIcon(null, g, 0, 0); g.dispose(); Image i = GrayFilter.createDisabledImage(bi); return new ImageIcon(i); } }
/** * Creates a modal dialog to display the given exception message. * * @param owner if non-null, then the dialog is positioned (centered) w.r.t. this component * @param icon the icon to display * @param t the exception to display */ public ErrorDialog(JComponent owner, Icon icon, Throwable t) { setTitle(t.getClass().getName()); setModal(true); if (icon instanceof ImageIcon) { setIconImage(((ImageIcon) icon).getImage()); } setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); error = t; message = createErrorMessage(error); main = createContent(); getContentPane().add(main); pack(); position(this, owner); }
if (img.getImage() instanceof BufferedImage) { BufferedImage image = (BufferedImage) img.getImage(); return new GraphicStyle2D(image, 0, 0); new BufferedImage( icon.getIconWidth() + border * 2, icon.getIconHeight() + border * 2,
@Override public void paintComponent(Graphics g) { final Dimension size = pane.getSize(); int x = (size.width - icon.getIconWidth()) / 2; int y = (size.height - icon.getIconHeight()) / 2; // Approach 1: Dispaly image at at full size g.setColor(Color.white); g.fillRect(0, 0, size.width, size.height); g.drawImage(icon.getImage(), x, y, null); setOpaque(false); super.paintComponent(g); }
protected void paintComponent(Graphics g) { super.paintComponent(g); setBackground(Color.WHITE); // draw logo g.drawImage(logoIcon.getImage(), getWidth()/2 - logoIcon.getIconWidth()/2, getHeight()/2 - logoIcon.getIconHeight()/2, logoIcon.getIconWidth(), logoIcon.getIconHeight(), logoIcon.getImageObserver()); drawVersionString(g, logoIcon); }
Image img = new ImageIcon("duke.png").getImage(); BufferedImage bi = new BufferedImage(SCALE * img.getWidth(null), SCALE * img.getHeight(null), BufferedImage.TYPE_INT_ARGB); grph.drawImage(img, 0, 0, null); grph.dispose();
String path = "resources/back_img.png"; ClassLoader cl = ImageHandler.class.getClassLoader(); URL imgURL = cl.getResource(path); //URL imgURL = ImageHandler.class.getResource(path); if (imgURL != null) { ImageIcon icon = new ImageIcon(imgURL, description); Image img = icon.getImage(); Image sizedImg = img.getScaledInstance(width, height, Image.SCALE_DEFAULT); return new ImageIcon(sizedImg); } else { System.err.println("Couldn't find file: " + path); return null; }