Example #1
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.IsTrue(TestTools.ComputeSHA1(extracted.Data, extracted.DataSize).Equals(TestTools.GetInstance().Checksum["AtlasTexLibrary_Extract_" + nameWOExtension + ".dds"]));

            extracted.Dispose();

            atlas.Dispose();
        }
Example #2
0
 public static TestTools GetInstance()
 {
     if (instance == null)
     {
         instance = new TestTools();
     }
     return instance;
 }
Example #3
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.IsTrue(TestTools.ComputeSHA1(atlas.Data, atlas.DataSize).Equals(TestTools.GetInstance().Checksum["AtlasTexLibrary_Update_" + textureNameToUpdate + "_" + atlasFile]));

            updateTexture.Dispose();
            atlas.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.IsFalse(library.CanHandleRequest(atlas, new DecompressingRequest(false)));
            Assert.IsTrue(library.CanHandleRequest(atlas, new AtlasCreationRequest(new List <TexImage>())));
            Assert.IsTrue(library.CanHandleRequest(atlas, new AtlasExtractionRequest(0)));
            Assert.IsTrue(library.CanHandleRequest(atlas, new AtlasUpdateRequest(new TexImage(), "")));
            atlas.Dispose();
        }
Example #5
0
        public void ExtractTest(string arrayFile, int indice)
        {
            TexImage array = TestTools.Load(dxtLib, arrayFile);

            var request = new ArrayExtractionRequest(indice, 16);

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

            var extracted = request.Texture;

            //Console.WriteLine("ArrayTexLibrary_Extract_" + arrayFile + "." + TestTools.ComputeSHA1(extracted.Data, extracted.DataSize));
            Assert.IsTrue(TestTools.ComputeSHA1(extracted.Data, extracted.DataSize).Equals(TestTools.GetInstance().Checksum["ArrayTexLibrary_Extract_" + arrayFile]));

            extracted.Dispose();

            array.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.IsTrue(list.Count == request.Textures.Count);

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

            atlas.Dispose();

            foreach (var image in list)
            {
                image.Dispose();
            }
        }
Example #7
0
        public void ExtractAllTest(string file1, string file2)
        {
            var list = new List <TexImage>();

            for (int i = 0; i < 5; ++i)
            {
                list.Add(texTool.Load(TestTools.InputTestFolder + file1));
                //Console.WriteLine("ArrayTexLibrary_ExtractAll_" + Path.GetFileName(file1) + "." + TestTools.ComputeSHA1(temp.Data, temp.DataSize));

                list.Add(texTool.Load(TestTools.InputTestFolder + file2));
                //Console.WriteLine("ArrayTexLibrary_ExtractAll_" + Path.GetFileName(file2) + "." + TestTools.ComputeSHA1(temp.Data, temp.DataSize));
            }

            var array = texTool.CreateTextureArray(list);

            var extracted = texTool.ExtractAll(array);

            Assert.IsTrue(list.Count == extracted.Count);

            for (int i = 0; i < array.ArraySize; ++i)
            {
                Assert.IsTrue(TestTools.ComputeSHA1(extracted[i].Data, extracted[i].DataSize).Equals(TestTools.GetInstance().Checksum["ExtractAll_" + list[i].Name]));
                extracted[i].Dispose();
            }

            array.Dispose();

            foreach (var image in list)
            {
                image.Dispose();
            }
        }
Example #8
0
        public void ExtractTest(string arrayFile, int indice)
        {
            TexImage array = texTool.Load(TestTools.InputTestFolder + arrayFile);

            var extracted = texTool.Extract(array, indice);

            //Console.WriteLine("TextureTool_Extract_" + indice + "_" + arrayFile + "." + TestTools.ComputeSHA1(extracted.Data, extracted.DataSize));
            Assert.IsTrue(TestTools.ComputeSHA1(extracted.Data, extracted.DataSize).Equals(TestTools.GetInstance().Checksum["TextureTool_Extract_" + indice + "_" + arrayFile]));

            extracted.Dispose();
            array.Dispose();
        }
Example #9
0
        public void ExtractAllAtlasTest(string atlasFile)
        {
            string[] fileList = Directory.GetFiles(TestTools.InputTestFolder + "atlas/");
            var      list     = new List <TexImage>(fileList.Length);

            foreach (string filePath in fileList)
            {
                list.Add(texTool.Load(filePath));
            }

            var atlas = texTool.CreateAtlas(list);

            var extracted = texTool.ExtractAll(atlas);

            Assert.IsTrue(extracted.Count == list.Count);

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

            atlas.Dispose();

            foreach (var image in list)
            {
                image.Dispose();
            }
        }
Example #10
0
        public void ExtractAtlasTest(string atlasFile, string textureName)
        {
            var atlas     = texTool.LoadAtlas(TestTools.InputTestFolder + atlasFile);
            var extracted = texTool.Extract(atlas, textureName, 16);

            Assert.IsTrue(TestTools.ComputeSHA1(extracted.Data, extracted.DataSize).Equals(TestTools.GetInstance().Checksum["TextureTool_ExtractAtlas_" + atlasFile + "_" + textureName]));
            //Console.WriteLine("TextureTool_ExtractAtlas_" + atlasFile + "_" + textureName + "." + TestTools.ComputeSHA1(extracted.Data, extracted.DataSize));

            extracted.Dispose();
            atlas.Dispose();
        }
Example #11
0
        public void ProcessingTest(string source, string extension, Filter.Rescaling rescaleFiler, SiliconStudio.Paradox.Graphics.PixelFormat format)
        {
            var image = texTool.Load(TestTools.InputTestFolder + source);

            texTool.CorrectGamma(image, 2.2);

            texTool.Rescale(image, 0.5f, 0.5f, rescaleFiler);

            texTool.GenerateMipMaps(image, Filter.MipMapGeneration.Box);

            var normalMap = texTool.GenerateNormalMap(image, 4);

            texTool.CorrectGamma(normalMap, 1 / 2.2);

            string output = "TextureTool_ProcessingTest_NormalMap" + rescaleFiler + "_" + format + "_" + source + extension;

            texTool.Save(normalMap, TestTools.TempFolder + output, format, normalMap.Width / 2);
            normalMap.Dispose();

            Assert.IsTrue(TestTools.ComputeSHA1(TestTools.TempFolder + output).Equals(TestTools.GetInstance().Checksum[output]));
            //Console.WriteLine(output + "." + TestTools.ComputeSHA1(TestTools.TempFolder + output));
            File.Delete(TestTools.TempFolder + output);

            texTool.Flip(image, Orientation.Horizontal);

            texTool.CorrectGamma(image, 1 / 2.2);

            output = "TextureTool_ProcessingTest_" + rescaleFiler + "_" + format + "_" + source + extension;
            texTool.Save(image, TestTools.TempFolder + output, format, 4);
            image.Dispose();

            Assert.IsTrue(TestTools.ComputeSHA1(TestTools.TempFolder + output).Equals(TestTools.GetInstance().Checksum[output]));
            //Console.WriteLine(output + "." + TestTools.ComputeSHA1(TestTools.TempFolder + output));
            File.Delete(TestTools.TempFolder + output);

            image.Dispose();
        }