Search in sources :

Example 1 with AssetData

use of com.github.jakz.romlib.data.assets.AssetData in project rom-manager by Jakz.

the class InfoPanel method setImage.

void setImage(Game rom, Asset asset, JLabel dest) {
    AssetData data = rom.getAssetData(asset);
    if (data.isPresent()) {
        Asset.Image imageAsset = (Asset.Image) asset;
        Dimension size = imageAsset.getSize();
        ImageIcon i = data.asImage();
        Image img = i.getImage();
        BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.createGraphics();
        g.drawImage(img, 0, 0, size.width, size.height, null);
        dest.setText("");
        dest.setIcon(new ImageIcon(bi));
    } else {
        dest.setText("Asset Missing");
        dest.setIcon(null);
    }
}
Also used : Graphics(java.awt.Graphics) ImageIcon(javax.swing.ImageIcon) Asset(com.github.jakz.romlib.data.assets.Asset) AssetData(com.github.jakz.romlib.data.assets.AssetData) Dimension(java.awt.Dimension) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Asset (com.github.jakz.romlib.data.assets.Asset)1 AssetData (com.github.jakz.romlib.data.assets.AssetData)1 Dimension (java.awt.Dimension)1 Graphics (java.awt.Graphics)1 Image (java.awt.Image)1 BufferedImage (java.awt.image.BufferedImage)1 ImageIcon (javax.swing.ImageIcon)1