Java Utililty Methods BufferedImage Load

List of utility methods to do BufferedImage Load

Description

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

Method

BufferedImageloadImage(String classRelativeFile)
load Image
InputStream is = ClassLoader.getSystemResourceAsStream(classRelativeFile);
if (is == null) {
    throw new IOException();
return ImageIO.read(is);
BufferedImageloadImage(String filename)
Loads the given file location as a buffered image Returns null if the image is not found
BufferedImage img = null;
try {
    return ImageIO.read(new File(filename));
} catch (IOException e) {
    e.printStackTrace();
    return null;
ImageloadImage(String fileName)
Carga una imagen y retorna una instancia de la misma.
InputStream stream = ClassLoader.getSystemResourceAsStream(fileName);
if (stream == null) {
    return ImageIO.read(new File(fileName));
} else {
    return ImageIO.read(stream);
ImageloadImage(String fileName, Component c)
return an Image loaded by a MediaTracker.
MediaTracker tracker = new MediaTracker(c);
Toolkit toolkit = c.getToolkit();
Image image = toolkit.getImage(fileName);
tracker.addImage(image, 0);
tracker.waitForAll();
return image;
ImageloadImage(String fileName, Component component)
load Image
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(fileName);
MediaTracker mediaTracker = new MediaTracker(component);
mediaTracker.addImage(image, 0);
try {
    mediaTracker.waitForID(0);
} catch (InterruptedException ie) {
    return null;
...
BufferedImageloadImage(String filePath)
load image
try {
    return ImageIO.read(new File(filePath));
} catch (Exception e) {
    throw new RuntimeException(e);
BufferedImageloadImage(String i, int x, int imageWidth, int imageHeight)
load Image
try {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gs.getDefaultConfiguration();
    BufferedImage tempBuff = ImageIO.read(new File(i));
    BufferedImage a = gc.createCompatibleImage(imageWidth, imageHeight, Transparency.TRANSLUCENT);
    Graphics tempG = a.getGraphics();
    tempG.drawImage(tempBuff.getSubimage(x, 0, imageWidth, imageHeight), 0, 0, null);
...
BufferedImageloadImage(String image)
Loads an image
return ImageIO.read(new File(image));
ImageloadImage(String imageName)
Loads an image from the given path.
URL imageUrl = Thread.currentThread().getContextClassLoader().getResource(IMAGE_PATH + imageName);
if (imageUrl == null) {
    throw new IllegalArgumentException("'" + imageName + "' could not be found in classpath");
return Toolkit.getDefaultToolkit().getImage(imageUrl);
ImageloadImage(String imageName, Component c)
Loads image
MediaTracker tracker = new MediaTracker(c);
Image img = Toolkit.getDefaultToolkit().createImage(imageName);
tracker.addImage(img, 0);
try {
    tracker.waitForID(0);
} catch (InterruptedException ie) {
return img;
...