package me.teridax.jcash.gui;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Objects;

import static me.teridax.jcash.Logging.LOGGER;

public class IconProvider {

    private static final Image DEFAULT_IMAGE = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB);

    public static Image getWindowIcon() {
        return loadIcon("res/register.png");
    }

    private static Image loadIcon(String path) {
        try {
            var is = Objects.requireNonNull(IconProvider.class.getResourceAsStream(path));
            return ImageIO.read(is);
        } catch (Exception e) {
            LOGGER.severe("Unable to load icon " + path + " because: " + e.getMessage());
        }

        return DEFAULT_IMAGE;
    }

    public static Image getBackground() {
        return loadIcon("res/background.png");
    }
}
