List of usage examples for javax.imageio ImageIO read
public static BufferedImage read(ImageInputStream stream) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { String mapUrlPath = "http://www.java2s.com/style/download.png"; URL mapUrl = new URL(mapUrlPath); BufferedImage mapImage = ImageIO.read(mapUrl); Image newMapImage = Toolkit.getDefaultToolkit() .createImage(new FilteredImageSource(mapImage.getSource(), new XorFilter())); ImageIcon mapIcon = new ImageIcon(mapImage); ImageIcon newMapIcon = new ImageIcon(newMapImage); JPanel imagePanel = new JPanel(); imagePanel.add(new JLabel(mapIcon)); imagePanel.add(new JLabel(newMapIcon)); JOptionPane.showMessageDialog(null, imagePanel); }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override/*from www . j a v a 2 s .com*/ public void run() { try { Image img = null; img = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new ImagePanel(img)); frame.pack(); frame.setVisible(true); } catch (Exception exp) { exp.printStackTrace(); } } }); }
From source file:Main.java
public static void main(String[] args) throws Exception { String mapUrlPath = "http://www.java2s.com/style/download.png"; URL mapUrl = new URL(mapUrlPath); BufferedImage mapImage = ImageIO.read(mapUrl); Image newMapImage = Toolkit.getDefaultToolkit() .createImage(new FilteredImageSource(mapImage.getSource(), new GrayFilter())); ImageIcon mapIcon = new ImageIcon(mapImage); ImageIcon newMapIcon = new ImageIcon(newMapImage); JPanel imagePanel = new JPanel(); imagePanel.add(new JLabel(mapIcon)); imagePanel.add(new JLabel(newMapIcon)); JOptionPane.showMessageDialog(null, imagePanel); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); BufferedImage bi = ImageIO.read(url); for (float q = 0.2f; q < .9f; q += .2f) { OutputStream outStream = new FileOutputStream(new File("c:/Java_Dev/Image-" + q + ".jpg")); ImageWriter imgWriter = ImageIO.getImageWritersByFormatName("jpg").next(); ImageOutputStream ioStream = ImageIO.createImageOutputStream(outStream); imgWriter.setOutput(ioStream);//from w w w .j ava 2 s . c o m JPEGImageWriteParam jpegParams = new JPEGImageWriteParam(Locale.getDefault()); jpegParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); jpegParams.setCompressionQuality(q); imgWriter.write(null, new IIOImage(bi, null, null), jpegParams); ioStream.flush(); ioStream.close(); imgWriter.dispose(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { String mapUrlPath = "http://www.java2s.com/style/download.png"; URL mapUrl = new URL(mapUrlPath); BufferedImage mapImage = ImageIO.read(mapUrl); Image newMapImage = Toolkit.getDefaultToolkit() .createImage(new FilteredImageSource(mapImage.getSource(), new GrayToColorFilter(Color.red))); ImageIcon mapIcon = new ImageIcon(mapImage); ImageIcon newMapIcon = new ImageIcon(newMapImage); JPanel imagePanel = new JPanel(); imagePanel.add(new JLabel(mapIcon)); imagePanel.add(new JLabel(newMapIcon)); JOptionPane.showMessageDialog(null, imagePanel); }
From source file:Main.java
public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage image = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); f.getContentPane().add(new JLabel(new ImageIcon(dye(image, new Color(255, 0, 0, 128))))); f.pack();/*from w ww .ja v a 2 s . com*/ f.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame f = new JFrame(Main.class.getSimpleName()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage bi = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel(new ImageIcon(bi)); panel.add(label);/*www .ja va 2 s .c o m*/ MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1); ((JPanel) e.getSource()).scrollRectToVisible(r); } }; panel.addMouseMotionListener(doScrollRectToVisible); panel.setAutoscrolls(true); f.add(new JScrollPane(panel)); f.pack(); f.setSize(f.getWidth() / 2, f.getHeight() / 2); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); final BufferedImage originalImage = ImageIO.read(url); int width = originalImage.getWidth(); int height = originalImage.getHeight(); final BufferedImage textImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = textImage.createGraphics(); FontRenderContext frc = g.getFontRenderContext(); Font font = new Font("Arial", Font.BOLD, 50); GlyphVector gv = font.createGlyphVector(frc, "java2s.com"); int xOff = 0; int yOff = 50; Shape shape = gv.getOutline(xOff, yOff); g.setClip(shape);//from w w w .j a va2 s . c o m g.drawImage(originalImage, 0, 0, null); g.setStroke(new BasicStroke(2f)); g.setColor(Color.BLACK); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.draw(shape); g.dispose(); ImageIO.write(textImage, "png", new File("cat-text.png")); SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(textImage))); } }); }
From source file:Main.java
public static void main(final String[] args) throws IOException { final URL url1 = new URL("http://www.java2s.com/style/download.png"); final URL url2 = new URL("http://www.java2s.com/style/download.png"); final URL url3 = new URL("http://www.java2s.com/style/download.png"); final PictureDesktop desktop = new PictureDesktop(); desktop.addPicture(ImageIO.read(url1)); desktop.addPicture(ImageIO.read(url2)); desktop.addPicture(ImageIO.read(url3)); final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(BorderLayout.CENTER, desktop); frame.setSize(720, 480);/*www. j av a 2 s. com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = ge.getDefaultScreenDevice(); if (!screen.isFullScreenSupported()) { System.out.println("Full screen mode not supported"); System.exit(1);//from www .j av a 2s . co m } try { BufferedImage loadedpic = ImageIO.read(new File("your.jpg")); screen.setFullScreenWindow(new Main(loadedpic)); } catch (Exception e) { System.err.println(e.getMessage()); } }