Skip to content

Commit

Permalink
Fixed converting dds files without mip maps to ftex. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Atvaark committed Jan 7, 2015
1 parent 3520fe7 commit 754e1e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions FtexTool/FtexDdsConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -187,7 +187,8 @@ private static List<byte[]> 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];
Expand Down
4 changes: 2 additions & 2 deletions FtexTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
4 changes: 2 additions & 2 deletions PftxsTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 754e1e1

Please sign in to comment.