Example #1
0
        public void ExportArrayTest(string fileName, string extension, int minMipMapSize)
        {
            DxtTexLib lib   = new DxtTexLib();
            TexImage  image = new TexImage();

            lib.Execute(image, new LoadingRequest(Module.PathToInputImages + fileName + extension, false));
            lib.EndLibrary(image);
            library.StartLibrary(image);

            library.Execute(image, new ExportRequest(Module.PathToOutputImages + "FITexLibTest_ExportArrayTest_" + fileName + ".png", minMipMapSize));

            int ct = 0;

            for (int i = 0; i < image.ArraySize; ++i)
            {
                for (int j = 0; j < image.MipmapCount; ++j)
                {
                    if (image.SubImageArray[ct].Height < minMipMapSize || image.SubImageArray[ct].Width < minMipMapSize)
                    {
                        break;
                    }
                    string file = Module.PathToOutputImages + "FITexLibTest_ExportArrayTest_" + fileName + "-ind_" + i + "-mip_" + j + ".png";
                    Assert.True(File.Exists(file));

                    //Console.WriteLine("FITexLibTest_ExportArrayTest_" + minMipMapSize + "_" + fileName + "-ind_" + i + "-mip_" + j + ".png" + "." + TestTools.ComputeSHA1(file));
                    Assert.Equal(TestTools.GetInstance().Checksum["FITexLibTest_ExportArrayTest_" + minMipMapSize + "_" + fileName + "-ind_" + i + "-mip_" + j + ".png"], TestTools.ComputeSHA1(file));
                    File.Delete(file);
                    ++ct;
                }
            }

            image.Dispose();
        }
Example #2
0
        public void ExtractTest(string atlasFile, string extractedName)
        {
            TexAtlas atlas = new TexAtlas(TexAtlas.TexLayout.Import(Module.PathToInputImages + Path.GetFileNameWithoutExtension(atlasFile) + TexAtlas.TexLayout.Extension), TestTools.Load(dxtLib, atlasFile));

            var request = new AtlasExtractionRequest(extractedName, 16);

            library.Execute(atlas, request);
            atlas.CurrentLibrary = library;

            var extracted = request.Texture;

            string nameWOExtension = Path.GetFileNameWithoutExtension(extractedName);

            //Console.WriteLine("AtlasTexLibrary_Extract_" + nameWOExtension + ".dds." + TestTools.ComputeSHA1(extracted.Data, extracted.DataSize));
            Assert.Equal(TestTools.GetInstance().Checksum["AtlasTexLibrary_Extract_" + nameWOExtension + ".dds"], TestTools.ComputeSHA1(extracted.Data, extracted.DataSize));

            extracted.Dispose();

            atlas.Dispose();
        }
Example #3
0
        public void CreateAtlasTest(string directory, bool generateMipMaps, bool forceSquaredAtlas)
        {
            string path = Module.PathToInputImages + directory;

            string[] fileList = Directory.GetFiles(path);
            var      list     = new List <TexImage>(fileList.Length);

            foreach (string filePath in fileList)
            {
                var temp = Load(fiLib, filePath);
                list.Add(temp);
                if (generateMipMaps)
                {
                    fiLib.EndLibrary(temp);
                    dxtLib.StartLibrary(temp);
                    dxtLib.Execute(temp, new MipMapsGenerationRequest(Filter.MipMapGeneration.Cubic));
                    temp.CurrentLibrary = dxtLib;
                }
            }

            var atlas = new TexAtlas();

            library.Execute(atlas, new AtlasCreationRequest(list, forceSquaredAtlas));

            //Console.WriteLine("AtlasTexLibrary_CreateAtlas_" + generateMipMaps + "_" + forceSquaredAtlas + "." + TestTools.ComputeSHA1(atlas.Data, atlas.DataSize));
            Assert.Equal(TestTools.GetInstance().Checksum["AtlasTexLibrary_CreateAtlas_" + generateMipMaps + "_" + forceSquaredAtlas], TestTools.ComputeSHA1(atlas.Data, atlas.DataSize));

            if (forceSquaredAtlas)
            {
                Assert.True(atlas.Width == atlas.Height);
            }

            atlas.Dispose();

            foreach (var image in list)
            {
                image.Dispose();
            }
        }
Example #4
0
        public void CanHandleRequestTest()
        {
            TexAtlas atlas = new TexAtlas(TexAtlas.TexLayout.Import(Module.PathToInputImages + Path.GetFileNameWithoutExtension("atlas_WMipMaps.dds") + TexAtlas.TexLayout.Extension), TestTools.Load(dxtLib, "atlas_WMipMaps.dds"));

            Assert.False(library.CanHandleRequest(atlas, new DecompressingRequest(false)));
            Assert.True(library.CanHandleRequest(atlas, new AtlasCreationRequest(new List <TexImage>())));
            Assert.True(library.CanHandleRequest(atlas, new AtlasExtractionRequest(0)));
            Assert.True(library.CanHandleRequest(atlas, new AtlasUpdateRequest(new TexImage(), "")));
            atlas.Dispose();
        }
Example #5
0
        public void UpdateTest(string atlasFile, string textureNameToUpdate, string newTexture)
        {
            TexAtlas atlas = new TexAtlas(TexAtlas.TexLayout.Import(Module.PathToInputImages + Path.GetFileNameWithoutExtension(atlasFile) + TexAtlas.TexLayout.Extension), TestTools.Load(fiLib, atlasFile));

            var updateTexture = TestTools.Load(fiLib, newTexture);

            library.Execute(atlas, new AtlasUpdateRequest(updateTexture, textureNameToUpdate));
            library.EndLibrary(atlas);

            //Console.WriteLine("AtlasTexLibrary_Update_" + textureNameToUpdate + "_" + atlasFile + "." + TestTools.ComputeSHA1(atlas.Data, atlas.DataSize));
            Assert.Equal(TestTools.GetInstance().Checksum["AtlasTexLibrary_Update_" + textureNameToUpdate + "_" + atlasFile], TestTools.ComputeSHA1(atlas.Data, atlas.DataSize));

            updateTexture.Dispose();
            atlas.Dispose();
        }
Example #6
0
        public void ExtractAllTest(string directory)
        {
            string path = Module.PathToInputImages + directory;

            string[] fileList = Directory.GetFiles(path);
            var      list     = new List <TexImage>(fileList.Length);

            foreach (string filePath in fileList)
            {
                var temp = Load(fiLib, filePath);
                list.Add(temp);
                //Console.WriteLine("ExtractAll_" + Path.GetFileName(filePath) + "." + TestTools.ComputeSHA1(temp.Data, temp.DataSize));
            }

            var atlas = new TexAtlas();

            library.Execute(atlas, new AtlasCreationRequest(list));

            var request = new AtlasExtractionRequest(0);

            library.Execute(atlas, request);
            library.EndLibrary(atlas);

            Assert.True(list.Count == request.Textures.Count);

            foreach (var image in request.Textures)
            {
                Assert.Equal(TestTools.GetInstance().Checksum["ExtractAll_" + image.Name], TestTools.ComputeSHA1(image.Data, image.DataSize));
                image.Dispose();
            }

            atlas.Dispose();

            foreach (var image in list)
            {
                image.Dispose();
            }
        }