Java BufferedImage Load loadImage(URL url)

Here you can find the source of loadImage(URL url)

Description

Load an image from a given URL.

License

Open Source License

Parameter

Parameter Description
url the URL of the image to load.

Exception

Parameter Description
InterruptedException an exception

Return

the loaded image

Declaration

public static Image loadImage(URL url) throws InterruptedException 

Method Source Code


//package com.java2s;
/*/*from w  w  w . jav a 2s  .  c  om*/
 * Scriptographer
 *
 * This file is part of Scriptographer, a Scripting Plugin for Adobe Illustrator
 * http://scriptographer.org/
 *
 * Copyright (c) 2002-2010, Juerg Lehni
 * http://scratchdisk.com/
 *
 * All rights reserved. See LICENSE file for details.
 * 
 * File created on May 11, 2007.
 */

import java.awt.Image;
import java.awt.MediaTracker;

import java.net.URL;

public class Main {
    /**
     * Load an image from a given URL. This blocks until the image is
     * loaded or an error occured.
     * @param url the URL of the image to load.
     * @return the loaded image
     * @throws InterruptedException
     */
    public static Image loadImage(URL url) throws InterruptedException {
        MediaTracker tracker = new MediaTracker(new java.awt.Container());
        Image img = java.awt.Toolkit.getDefaultToolkit().createImage(url);
        tracker.addImage(img, 0);
        tracker.waitForAll();
        return img;
    }
}

Related

  1. loadImage(String path)
  2. loadImage(String path)
  3. loadImage(String resourceName)
  4. loadImage(String url)
  5. loadImage(URL resource)
  6. loadImageData(BufferedImage image)
  7. loadImageData(String name)
  8. loadImageFromBytes(byte[] bytes)
  9. loadImageFromFile(File f)