diff --git a/cicaprojekt/ImageStorage.java b/cicaprojekt/ImageStorage.java new file mode 100644 index 0000000..8b980af --- /dev/null +++ b/cicaprojekt/ImageStorage.java @@ -0,0 +1,31 @@ +package cicaprojekt; + +import javax.imageio.ImageIO; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + + +public class ImageStorage { + private Map images; + + public ImageStorage() throws IOException { + images = new HashMap<>(); + + File dir = new File(System.getProperty("user.dir")); + FileNameExtensionFilter filter = new FileNameExtensionFilter("N/A", "png"); + + for (File f : dir.listFiles()) { + if (filter.accept(f) && f.isFile()){ + images.put(f.getName(), ImageIO.read(f)); + } + } + } + + public BufferedImage getImage(String filename) { + return images.get(filename); + } +}