mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-26 12:41:49 +01:00
Add NRO icon loading
This commit is contained in:
parent
892960e8fd
commit
e84e0c7705
@ -1,8 +1,13 @@
|
||||
package gq.cyuubi.lightswitch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
final class TitleEntry {
|
||||
@ -54,4 +59,34 @@ public class NroMeta {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String LoadImage(String file, MainActivity context) {
|
||||
try {
|
||||
RandomAccessFile f = new RandomAccessFile(file, "r");
|
||||
f.seek(0x18); // Skip to NroHeader.size
|
||||
int asetOffset = Integer.reverseBytes(f.readInt());
|
||||
f.seek(asetOffset); // Skip to the offset specified by NroHeader.size
|
||||
byte[] buffer = new byte[4];
|
||||
f.read(buffer);
|
||||
if(!(new String(buffer).equals("ASET")))
|
||||
return null;
|
||||
|
||||
f.skipBytes(0x4);
|
||||
long iconOffset = Long.reverseBytes(f.readLong());
|
||||
long iconSize = Long.reverseBytes(f.readLong());
|
||||
if(iconOffset == 0 || iconSize == 0)
|
||||
return null;
|
||||
f.seek(asetOffset + iconOffset);
|
||||
|
||||
byte[] iconData = new byte[(int)iconSize];
|
||||
f.read(iconData);
|
||||
|
||||
new FileOutputStream(context.getFilesDir() + "/tmp.jpg").write(iconData);
|
||||
return context.getFilesDir() + "/tmp.jpg";
|
||||
}
|
||||
catch(IOException e) {
|
||||
Log.e("app_process64", "Error while loading ASET: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user