mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 04:08:26 -05:00
Relocate JPEG code
-14 lines
This commit is contained in:
@@ -516,6 +516,8 @@ public bool DaycareOccupied2
|
||||
|
||||
public byte[] getWondercard(int i) { return Data.Skip(WondercardData + i*WC6.Size).Take(WC6.Size).ToArray(); }
|
||||
public void setWondercard(int i, byte[] data) { data.CopyTo(data, WondercardData + i * WC6.Size); }
|
||||
public string JPEGTitle => JPEG > -1 ? null : Util.TrimFromZero(Encoding.Unicode.GetString(Data, JPEG, 0x1A));
|
||||
public byte[] JPEGData => JPEG > -1 || Data[JPEG + 0x54] != 0xFF ? null : Data.Skip(JPEG + 0x54).Take(0xE004).ToArray();
|
||||
|
||||
// Data Accessing
|
||||
public byte[] getData(int Offset, int Length)
|
||||
|
||||
@@ -3278,29 +3278,13 @@ private void B_OpenSecretBase_Click(object sender, EventArgs e)
|
||||
}
|
||||
private void B_JPEG_Click(object sender, EventArgs e)
|
||||
{
|
||||
int offset = SAV.JPEG;
|
||||
string filename = Encoding.Unicode.GetString(SAV.Data, offset, 0x1A).Trim();
|
||||
filename += "'s picture";
|
||||
offset += 0x54;
|
||||
if (SAV.Data[offset] != 0xFF)
|
||||
{
|
||||
Util.Alert("No PGL picture data found in the save file!");
|
||||
return;
|
||||
}
|
||||
const int length = 0xE004;
|
||||
|
||||
byte[] jpeg = new byte[length];
|
||||
Array.Copy(SAV.Data, offset, jpeg, 0, length);
|
||||
SaveFileDialog savejpeg = new SaveFileDialog {FileName = filename, Filter = "JPEG|*.jpeg"};
|
||||
if (savejpeg.ShowDialog() != DialogResult.OK) return;
|
||||
string path = savejpeg.FileName;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
// File already exists, save a .bak
|
||||
byte[] backupfile = File.ReadAllBytes(path);
|
||||
File.WriteAllBytes(path + ".bak", backupfile);
|
||||
}
|
||||
File.WriteAllBytes(path, jpeg);
|
||||
byte[] jpeg = SAV.JPEGData;
|
||||
if (SAV.JPEGData == null)
|
||||
{ Util.Alert("No PGL picture data found in the save file!"); return; }
|
||||
string filename = SAV.JPEGTitle + "'s picture";
|
||||
SaveFileDialog sfd = new SaveFileDialog {FileName = filename, Filter = "JPEG|*.jpeg"};
|
||||
if (sfd.ShowDialog() != DialogResult.OK) return;
|
||||
File.WriteAllBytes(sfd.FileName, jpeg);
|
||||
}
|
||||
// Save Folder Related
|
||||
private void clickSaveFileName(object sender, EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user