mirror of
https://github.com/codestation/mhtools
synced 2024-11-10 05:44:17 +00:00
First attempt of a .pak decompiler
This commit is contained in:
parent
fce2d43421
commit
54f795453a
3 changed files with 23 additions and 5 deletions
|
@ -29,6 +29,7 @@ import dec.ExtractPluginA;
|
|||
import dec.ExtractPluginB;
|
||||
import dec.ExtractPluginC;
|
||||
import dec.ExtractPluginD;
|
||||
import dec.ExtractPluginE;
|
||||
import enc.RebuildPluginA;
|
||||
import enc.RebuildPluginB;
|
||||
import enc.RebuildPluginC;
|
||||
|
@ -59,6 +60,9 @@ public class Mhtrans {
|
|||
case 5:
|
||||
dec = new ExtractPluginD();
|
||||
break;
|
||||
case 6:
|
||||
dec = new ExtractPluginE();
|
||||
break;
|
||||
default:
|
||||
System.err.println("Unknown decoder: " + decoder);
|
||||
System.exit(1);
|
||||
|
|
|
@ -17,15 +17,18 @@
|
|||
|
||||
package dec;
|
||||
|
||||
|
||||
import img.Gim;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
import base.Decoder;
|
||||
import base.EndianFixer;
|
||||
|
||||
|
@ -38,8 +41,21 @@ public class ExtractPluginD extends EndianFixer implements Decoder {
|
|||
|
||||
@Override
|
||||
public void extract(String filename) {
|
||||
String directory = filename.split("\\.")[0];
|
||||
new File(directory).mkdir();
|
||||
try {
|
||||
FileInputStream file = new FileInputStream(filename);
|
||||
FileInputStream file = new FileInputStream(filename);
|
||||
extract(file, directory);
|
||||
file.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void extract(FileInputStream file, String directory) {
|
||||
try {
|
||||
byte header_id[] = new byte[8];
|
||||
file.read(header_id);
|
||||
int header_gim_count = readInt(file);
|
||||
|
@ -51,8 +67,6 @@ public class ExtractPluginD extends EndianFixer implements Decoder {
|
|||
int buffered_type = BufferedImage.TYPE_INT_ARGB;
|
||||
BufferedImage bi = new BufferedImage(gim.getWidth(), gim.getHeight(), buffered_type);
|
||||
bi.setRGB(0, 0, gim.getWidth(), gim.getHeight(), gim.getRGBarray(), 0, gim.getWidth());
|
||||
String directory = filename.split("\\.")[0];
|
||||
new File(directory).mkdir();
|
||||
String fileformat;
|
||||
String format;
|
||||
if(gim.getDataType() == Gim.GIM_TYPE_PALETTE)
|
||||
|
@ -82,8 +96,6 @@ public class ExtractPluginD extends EndianFixer implements Decoder {
|
|||
out.close();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
System.out.println("Finished!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package enc;
|
||||
|
||||
|
||||
import img.Gim;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -30,6 +31,7 @@ import java.util.Comparator;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
||||
import base.Encoder;
|
||||
import base.EndianFixer;
|
||||
|
||||
|
|
Loading…
Reference in a new issue