StudioDecompiler - hpgDesigns/hpgdesigns-dev.io GitHub Wiki

<source lang="Java> /**

  • @file Extractor.java

  • @brief Class implementing a .win resource extractor.

  • @section License

  • Copyright (C) 2013-2014 Robert B. Colton

  • This file is a part of the GameMaker: Studio decompiler.

  • This program is free software: you can redistribute it and/or modify

  • it under the terms of the GNU General Public License as published by

  • the Free Software Foundation, either version 3 of the License, or

  • (at your option) any later version.

  • This program is distributed in the hope that it will be useful,

  • but WITHOUT ANY WARRANTY; without even the implied warranty of

  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

  • GNU General Public License for more details.

  • You should have received a copy of the GNU General Public License

  • along with this program. If not, see <http://www.gnu.org/licenses/>.

    • /

import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException;

import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException;

public class Extractor {

   public static void main(String args[]) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {        // Set native Java L&F, otherwise file chooser looks like shit        UIManager.setLookAndFeel(            UIManager.getSystemLookAndFeelClassName());                JFileChooser fileChooser = new JFileChooser();        if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {            File file = fileChooser.getSelectedFile();                        FileInputStream fis = new FileInputStream(file);            int length = (int)file.length();              byte buffer[] = new byte [length];              fis.read(buffer);              fis.close();                        int tex = 0;                        for (int i = 0; i < length - 3; i++) {                if (buffer[i + 1] == 'P'                         && buffer[i + 2] == 'N'                        && buffer[i + 3] == 'G') {                    for (int ii = i + 4; ii < length - 3; ii++) {                        if (buffer[ii] == 'I' && buffer[ii + 1] == 'E'                                 && buffer[ii + 2] == 'N'                                && buffer[ii + 3] == 'D') {                            File imgfile = new File(file.getParent() + "/texture" + tex + ".png");                            tex += 1;                            FileOutputStream fos = new FileOutputStream(imgfile);                            fos.write(buffer, i, ii - i + 9);                            fos.close();                            i = ii + 8;                            break;                        }                    }                }            }            JOptionPane.showMessageDialog(null, tex + " Textures Extracted");        }    }

}

⚠️ **GitHub.com Fallback** ⚠️