import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.*;
import java.net.*;
/**
*
* @author Justin Mobijohn and Zander
*/
public class ImageManager extends Canvas {
/**
* Loads an image from disk into memory. It uses the URL function so that
* if this game were to be played in a browser, it would work.
* @param nameOfJPEG The relative path to the image to be loaded.
* @return BufferedImage
*/
public BufferedImage LoadImageFromDisk(String nameOfJPEG) {
URL url = null;
try {
url = getClass().getClassLoader().getResource(nameOfJPEG);
return ImageIO.read(url);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
System.exit(0);
return null;
}
}
}
|