Skip to content

Commit c35ef23

Browse files
authored
Merge pull request #11 from Yuuki-Walsh/master
Import / Export PNG support
2 parents d345078 + 5248545 commit c35ef23

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

xivModdingFramework/Helpers/IOUtil.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -123,37 +123,5 @@ public static string MakeItemSavePath(IItem item, DirectoryInfo saveDirectory, X
123123

124124
return path;
125125
}
126-
127-
/// <summary>
128-
/// Determines whether a DDS file exists for the given item
129-
/// </summary>
130-
/// <param name="item">The item to check</param>
131-
/// <param name="saveDirectory">The save directory where the DDS should be located</param>
132-
/// <param name="fileName">The name of the file</param>
133-
/// <returns>True if the DDS file exists, false otherwise</returns>
134-
public static bool DDSFileExists(IItem item, DirectoryInfo saveDirectory, string fileName, XivRace race = XivRace.All_Races)
135-
{
136-
var path = MakeItemSavePath(item, saveDirectory, race);
137-
138-
var fullPath = new DirectoryInfo($"{path}\\{fileName}.dds");
139-
140-
return File.Exists(fullPath.FullName);
141-
}
142-
143-
/// <summary>
144-
/// Determines whether a BMP file exists for the given item
145-
/// </summary>
146-
/// <param name="item">The item to check</param>
147-
/// <param name="saveDirectory">The save directory where the BMP should be located</param>
148-
/// <param name="fileName">The name of the file</param>
149-
/// <returns>True if the BMP file exists, false otherwise</returns>
150-
public static bool BMPFileExists(IItem item, DirectoryInfo saveDirectory, string fileName, XivRace race = XivRace.All_Races)
151-
{
152-
var path = MakeItemSavePath(item, saveDirectory, race);
153-
154-
var fullPath = new DirectoryInfo($"{path}\\{fileName}.bmp");
155-
156-
return File.Exists(fullPath.FullName);
157-
}
158126
}
159127
}

xivModdingFramework/Textures/FileTypes/Tex.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,13 @@ public async Task<int> TexDDSImporter(XivTex xivTex, IItem item, DirectoryInfo d
663663
return offset;
664664
}
665665

666-
public async Task<int> TexBMPImporter(XivTex xivTex, IItem item, DirectoryInfo bmpFileDirectory, string source)
666+
public async Task<int> TexImporter(XivTex xivTex, IItem item, DirectoryInfo fileDirectory, string source)
667667
{
668668
var offset = 0;
669669

670670
var modding = new Modding(_gameDirectory);
671671

672-
if (File.Exists(bmpFileDirectory.FullName))
672+
if (File.Exists(fileDirectory.FullName))
673673
{
674674
// Check if the texture being imported has been imported before
675675
var modEntry = await modding.TryGetModEntry(xivTex.TextureTypeAndPath.Path);
@@ -679,7 +679,7 @@ public async Task<int> TexBMPImporter(XivTex xivTex, IItem item, DirectoryInfo b
679679
switch (xivTex.TextureFormat)
680680
{
681681
case XivTexFormat.DXT1:
682-
compressionFormat = CompressionFormat.BC1;
682+
compressionFormat = CompressionFormat.BC1a;
683683
break;
684684
case XivTexFormat.DXT5:
685685
compressionFormat = CompressionFormat.BC3;
@@ -691,8 +691,11 @@ public async Task<int> TexBMPImporter(XivTex xivTex, IItem item, DirectoryInfo b
691691
throw new Exception($"Format {xivTex.TextureFormat} is not currently supported for BMP import\n\nPlease use the DDS import option instead.");
692692
}
693693

694-
using (var surface = Surface.LoadFromFile(bmpFileDirectory.FullName))
694+
using (var surface = Surface.LoadFromFile(fileDirectory.FullName))
695695
{
696+
if (surface == null)
697+
throw new FormatException($"Unsupported texture format");
698+
696699
surface.FlipVertically();
697700

698701
using (var compressor = new Compressor())
@@ -805,7 +808,7 @@ public async Task<int> TexBMPImporter(XivTex xivTex, IItem item, DirectoryInfo b
805808
}
806809
else
807810
{
808-
throw new IOException($"Could not find file: {bmpFileDirectory.FullName}");
811+
throw new IOException($"Could not find file: {fileDirectory.FullName}");
809812
}
810813

811814
return offset;

0 commit comments

Comments
 (0)