コード例 #1
0
ファイル: Program.cs プロジェクト: shdwdln/FtexTool
        private static void UnpackFtexFile(string filePath, string outputPath)
        {
            string fileDirectory = string.IsNullOrEmpty(outputPath) ? Path.GetDirectoryName(filePath) ?? string.Empty : outputPath;
            string fileName      = Path.GetFileNameWithoutExtension(filePath);

            FtexFile ftexFile = GetFtexFile(filePath);
            DdsFile  ddsFile  = FtexDdsConverter.ConvertToDds(ftexFile);

            string ddsFileName = $"{fileName}.dds";
            string ddsFilePath = Path.Combine(fileDirectory, ddsFileName);

            using (FileStream outputStream = new FileStream(ddsFilePath, FileMode.Create))
            {
                ddsFile.Write(outputStream);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: shdwdln/FtexTool
        private static void PackDdsFile(string filePath, string outputPath, FtexTextureType textureType, FtexUnknownFlags flags, int?ftexsFileCount)
        {
            string fileDirectory = String.IsNullOrEmpty(outputPath) ? Path.GetDirectoryName(filePath) ?? string.Empty : outputPath;
            string fileName      = Path.GetFileNameWithoutExtension(filePath);

            DdsFile  ddsFile  = GetDdsFile(filePath);
            FtexFile ftexFile = FtexDdsConverter.ConvertToFtex(
                ddsFile,
                textureType,
                flags,
                ftexsFileCount);

            string ftexFileName = $"{fileName}.ftex";
            string ftexFilePath = Path.Combine(fileDirectory, ftexFileName);

            using (FileStream ftexStream = new FileStream(ftexFilePath, FileMode.Create))
            {
                if (ftexsFileCount == 0)
                {
                    ftexStream.Seek(ftexFile.Size, SeekOrigin.Begin);
                }

                foreach (var ftexsFile in ftexFile.FtexsFiles)
                {
                    if (ftexsFileCount == 0)
                    {
                        ftexsFile.Write(ftexStream);
                    }
                    else
                    {
                        string ftexsFileName = $"{fileName}.{ftexsFile.FileNumber}.ftexs";
                        string ftexsFilePath = Path.Combine(fileDirectory, ftexsFileName);
                        using (FileStream ftexsStream = new FileStream(ftexsFilePath, FileMode.Create))
                        {
                            ftexsFile.Write(ftexsStream);
                        }
                    }
                }

                ftexFile.UpdateOffsets();
                ftexStream.Seek(0, SeekOrigin.Begin);
                ftexFile.Write(ftexStream);
            }
        }