Java Utililty Methods Image Load

List of utility methods to do Image Load

Description

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

Method

ImageloadImage(File original)
load Image
ImageIcon ii = new ImageIcon(original.getCanonicalPath());
Image i = ii.getImage();
return i;
BufferedImageloadImage(final String src)
Loads image from specified source file
return loadImage(new File(src));
BufferedImageloadImage(InputStream s)
load Image
Image img = Toolkit.getDefaultToolkit().createImage(loadBytes(s));
try {
    imageAssist.addImage(img, 1);
    imageAssist.waitForID(1);
    imageAssist.removeImage(img);
} catch (InterruptedException e) {
    throw new IOException("Interrupted while loading image");
BufferedImage bufImg = new BufferedImage(img.getWidth(null), img.getHeight(null),
        BufferedImage.TYPE_INT_ARGB);
bufImg.getGraphics().drawImage(img, 0, 0, null);
return bufImg;
BufferedImageloadImage(Object parent, String pathToImage)
load Image
BufferedImage bufferedImage = null;
ImageIcon imageIcon = null;
try {
    InputStream inputStream = parent.getClass().getResourceAsStream(pathToImage);
    bufferedImage = ImageIO.read(inputStream);
} catch (IOException e) {
    e.printStackTrace();
return bufferedImage;
ImageloadImage(String filename)
load Image
ImageIcon icon = new ImageIcon(filename);
return icon.getImage();
ImageloadImage(String filePath, int imageSize)
load Image
ImageIcon imgIcon = new ImageIcon(filePath);
if (imgIcon == null)
    return null;
return getScaledImage(imgIcon.getImage(), imageSize);
ImageloadImage(URL url)
load Image
if (url == null) {
    return null;
Image image = null;
try {
    image = Toolkit.getDefaultToolkit().getImage(url);
    if (image != null) {
        synchronized (tracker) {
...
ImageIconreadImage(InputStream inp)
read Image
byte[] bytes = readInBytes(inp);
return new ImageIcon(bytes);
voidreadImageToLabel(String netUrl)
read Image To Label
Image image = null;
try {
    URL url = new URL(netUrl);
    image = ImageIO.read(url);
} catch (IOException localIOException) {
JFrame frame = new JFrame();
JLabel label = new JLabel(new ImageIcon(image));
...