Skip to content

Commit

Permalink
Fix bug where tool was not releasing input files, and preventing edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebane1 committed Jan 24, 2023
1 parent 5814dd5 commit ea8c649
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 37 deletions.
Binary file modified .vs/FFXIVLooseTextureCompiler/v17/.suo
Binary file not shown.
6 changes: 3 additions & 3 deletions FFXIVLooseTextureCompiler/FFXIVLooseTextureCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyVersion>1.0.0.3</AssemblyVersion>
<FileVersion>1.0.0.3</FileVersion>
<Version>1.0.0.3</Version>
<AssemblyVersion>1.0.0.4</AssemblyVersion>
<FileVersion>1.0.0.4</FileVersion>
<Version>1.0.0.4</Version>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<Title>FFXIV Loose Texture Compiler</Title>
<Copyright>Lawener Industries</Copyright>
Expand Down
68 changes: 37 additions & 31 deletions FFXIVLooseTextureCompiler/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,17 @@ public void ExportTex(string inputFile, string outputFile, bool doNormal = false
if (!doNormal) {
TextureImporter.PngToTex(inputFile, out data);
} else {
Bitmap bitmap = new Bitmap(inputFile);
MemoryStream stream = new MemoryStream();
Bitmap target = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics g = Graphics.FromImage(target);
g.Clear(Color.White);
g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
Normal.Calculate(target).Save(stream, ImageFormat.Png);
stream.Position = 0;
TextureImporter.PngToTex(stream, out data);
using (Bitmap bitmap = new Bitmap(inputFile)) {
using (MemoryStream stream = new MemoryStream()) {
Bitmap target = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics g = Graphics.FromImage(target);
g.Clear(Color.White);
g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
Normal.Calculate(target).Save(stream, ImageFormat.Png);
stream.Position = 0;
TextureImporter.PngToTex(stream, out data);
}
}
}
} else if (inputFile.EndsWith(".dds")) {
var scratch = ScratchImage.LoadDDS(inputFile);
Expand All @@ -282,31 +284,35 @@ public void ExportTex(string inputFile, string outputFile, bool doNormal = false
if (!doNormal) {
TextureImporter.RgbaBytesToTex(ddsFile, f.Meta.Width, f.Meta.Height, out data);
} else {
Bitmap bitmap = Normal.Calculate(RGBAToBitmap(ddsFile, scratch.Meta.Width, scratch.Meta.Height));
MemoryStream stream = new MemoryStream();
Bitmap target = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics g = Graphics.FromImage(target);
g.Clear(Color.White);
g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
Normal.Calculate(target).Save(stream, ImageFormat.Png);
stream.Position = 0;
TextureImporter.PngToTex(stream, out data);
using (Bitmap bitmap = Normal.Calculate(RGBAToBitmap(ddsFile, scratch.Meta.Width, scratch.Meta.Height))) {
using (MemoryStream stream = new MemoryStream()) {
Bitmap target = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics g = Graphics.FromImage(target);
g.Clear(Color.White);
g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
Normal.Calculate(target).Save(stream, ImageFormat.Png);
stream.Position = 0;
TextureImporter.PngToTex(stream, out data);
}
}
}
} else if (inputFile.EndsWith(".bmp")) {
MemoryStream stream = new MemoryStream();
Bitmap bitmap = new Bitmap(inputFile);
if (doNormal) {
Bitmap target = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics g = Graphics.FromImage(target);
g.Clear(Color.White);
g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
Normal.Calculate(target).Save(stream, ImageFormat.Png);
} else {
bitmap.Save(stream, ImageFormat.Png);
using (MemoryStream stream = new MemoryStream()) {
using (Bitmap bitmap = new Bitmap(inputFile)) {
if (doNormal) {
Bitmap target = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
Graphics g = Graphics.FromImage(target);
g.Clear(Color.White);
g.DrawImage(bitmap, 0, 0, bitmap.Width, bitmap.Height);
Normal.Calculate(target).Save(stream, ImageFormat.Png);
} else {
bitmap.Save(stream, ImageFormat.Png);
}
stream.Flush();
stream.Position = 0;
TextureImporter.PngToTex(stream, out data);
}
}
stream.Flush();
stream.Position = 0;
TextureImporter.PngToTex(stream, out data);
} else if (inputFile.EndsWith(".tex")) {
data = File.ReadAllBytes(inputFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"projects": {
"C:\\Users\\stel9\\source\\repos\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler.csproj": {
"version": "1.0.0.3",
"version": "1.0.0.4",
"restore": {
"projectUniqueName": "C:\\Users\\stel9\\source\\repos\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler.csproj",
"projectName": "FFXIVLooseTextureCompiler",
Expand Down
2 changes: 1 addition & 1 deletion FFXIVLooseTextureCompiler/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0.3",
"version": "1.0.0.4",
"restore": {
"projectUniqueName": "C:\\Users\\stel9\\source\\repos\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler.csproj",
"projectName": "FFXIVLooseTextureCompiler",
Expand Down
2 changes: 1 addition & 1 deletion FFXIVLooseTextureCompiler/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "Z3xzH39W9fQ7ntyR+b/akUOQfW21tMlEB9wckCRnwhrtSb4tUqW8PbFKcFGtt3Oc8TFh8OOSDCz/lIwRTPf/3g==",
"dgSpecHash": "aitlClSZgFY3zDsX/iB1KW3MrQ3c7saAsLUb0SY02wQaU0MIC5uj9g5nos2OF13xwyqvYAPZlH5nm3XtCFvMBQ==",
"success": true,
"projectFilePath": "C:\\Users\\stel9\\source\\repos\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler\\FFXIVLooseTextureCompiler.csproj",
"expectedPackageFiles": [
Expand Down

0 comments on commit ea8c649

Please sign in to comment.