From 754e1e10dbc53784372d8c22c993a640e81514d7 Mon Sep 17 00:00:00 2001 From: Atvaark Date: Wed, 7 Jan 2015 19:05:52 +0100 Subject: [PATCH] Fixed converting dds files without mip maps to ftex. Fixes #2 --- FtexTool/FtexDdsConverter.cs | 7 ++++--- FtexTool/Properties/AssemblyInfo.cs | 4 ++-- PftxsTool/Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/FtexTool/FtexDdsConverter.cs b/FtexTool/FtexDdsConverter.cs index 6d56bb4..50e0376 100644 --- a/FtexTool/FtexDdsConverter.cs +++ b/FtexTool/FtexDdsConverter.cs @@ -67,12 +67,12 @@ public static FtexFile ConvertToFtex(DdsFile file, FtexTextureType textureType) result.Height = Convert.ToInt16(file.Header.Height); result.Width = Convert.ToInt16(file.Header.Width); result.Depth = Convert.ToInt16(file.Header.Depth); - result.MipMapCount = Convert.ToByte(file.Header.MipMapCount); - result.NrtFlag = 2; var mipMapData = GetMipMapData(file); var mipMaps = GetMipMapInfos(mipMapData); var ftexsFiles = GetFtexsFiles(mipMaps, mipMapData); + result.MipMapCount = Convert.ToByte(mipMaps.Count()); + result.NrtFlag = 2; result.AddMipMapInfos(mipMaps); result.AddFtexsFiles(ftexsFiles); result.FtexsFileCount = Convert.ToByte(ftexsFiles.Count()); @@ -187,7 +187,8 @@ private static List GetMipMapData(DdsFile file) int dataOffset = 0; var width = file.Header.Width; var height = file.Header.Height; - for (int i = 0; i < file.Header.MipMapCount; i++) + int mipMapsCount = file.Header.Flags.HasFlag(DdsFileHeaderFlags.MipMap) ? file.Header.MipMapCount : 1; + for (int i = 0; i < mipMapsCount; i++) { int size = DdsPixelFormat.CalculateImageSize(file.Header.PixelFormat, width, height); var buffer = new byte[size]; diff --git a/FtexTool/Properties/AssemblyInfo.cs b/FtexTool/Properties/AssemblyInfo.cs index b360879..007cc1c 100644 --- a/FtexTool/Properties/AssemblyInfo.cs +++ b/FtexTool/Properties/AssemblyInfo.cs @@ -10,5 +10,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("d87a6cb1-0454-4123-8fc6-23f50523de89")] -[assembly: AssemblyVersion("0.2.3.0")] -[assembly: AssemblyFileVersion("0.2.3.0")] +[assembly: AssemblyVersion("0.2.4.0")] +[assembly: AssemblyFileVersion("0.2.4.0")] diff --git a/PftxsTool/Properties/AssemblyInfo.cs b/PftxsTool/Properties/AssemblyInfo.cs index 24cb259..2d94df8 100644 --- a/PftxsTool/Properties/AssemblyInfo.cs +++ b/PftxsTool/Properties/AssemblyInfo.cs @@ -10,5 +10,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("d2802805-05c4-410c-9aec-a547bb671d1a")] -[assembly: AssemblyVersion("0.2.3.0")] -[assembly: AssemblyFileVersion("0.2.3.0")] +[assembly: AssemblyVersion("0.2.4.0")] +[assembly: AssemblyFileVersion("0.2.4.0")]