コード例 #1
0
        public TerrainCreator(Map map, IProjection projection, Elevation elevation,
                              Point offset, string modDir) : base(map, projection, elevation)
        {
            this.offset = offset;

            this.modDir          = modDir;
            satAbsoluteOutputDir = Path.Combine(modDir, satOutputDir);

            Utils.DeleteDirectoryContents(satAbsoluteOutputDir);

            ir = new ImageRetrieval
            {
                ImageFormat = MagickFormat.Dds,
                Labeled     = false
            };

            writeDefines = new DdsWriteDefines
            {
                Mipmaps     = 1,
                FastMipmaps = true,
            };

            satMat = MatFile.Open("Assets/sat_image_tmpl.mat");
            satMat.Attributes["aux[0]"][0] = XSize;
            satMat.Attributes["aux[0]"][1] = YSize;

            satTobj = Tobj.Open("Assets/sat_image_tmpl.tobj");
        }
コード例 #2
0
        public static void ConvertToDds(string path, bool delSource = false)
        {
            MagickImage img = IOUtils.ReadImage(path);

            if (img == null)
            {
                return;
            }
            img.Format = MagickFormat.Dds;
            DdsCompression compression = DdsCompression.None;

            if (Config.Get("ddsCompressionType").Contains("BC1"))
            {
                compression = DdsCompression.Dxt1;
            }
            int mips = 0;

            if (Config.GetBool("ddsEnableMips"))
            {
                mips = 8;
            }
            var defines = new DdsWriteDefines {
                Compression = compression, Mipmaps = mips, FastMipmaps = true
            };

            img.Settings.SetDefines(defines);
            string outPath = Path.ChangeExtension(path, null) + ".dds";

            PreProcessing(path);
            img.Write(outPath);
            PostProcessing(img, path, outPath, delSource);
        }
コード例 #3
0
        static async Task ConvertToDdsNative(string path)
        {
            MagickImage img = IOUtils.ReadImage(path);

            if (img == null)
            {
                return;
            }
            img.Format = MagickFormat.Dds;
            DdsCompression compression = DdsCompression.None;

            if ((await Config.Get("ddsCompressionType")).Contains("BC1"))
            {
                compression = DdsCompression.Dxt1;
            }

            int mips = 0;

            if (await Config.GetBool("ddsEnableMips"))
            {
                mips = await Config.GetInt("mipCount");
            }
            var defines = new DdsWriteDefines {
                Compression = compression, Mipmaps = mips, FastMipmaps = true
            };

            img.Settings.SetDefines(defines);
            string outPath = Path.ChangeExtension(path, null) + ".dds";

            IOUtils.SaveImage(img, outPath);
        }
コード例 #4
0
        public void Compression_NotSet_DefineIsNotSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines();

                image.Settings.SetDefines(defines);

                Assert.AreEqual(null, defines.Compression);
                Assert.AreEqual(null, image.Settings.GetDefine(MagickFormat.Dds, "compression"));
            }
        }
コード例 #5
0
        public void WeightByAlpha_NotSet_DefineIsNotSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines();

                image.Settings.SetDefines(defines);

                Assert.AreEqual(null, defines.WeightByAlpha);
                Assert.AreEqual(null, image.Settings.GetDefine(MagickFormat.Dds, "weight-by-alpha"));
            }
        }
コード例 #6
0
        public void ClusterFit_NotSet_DefineIsNotSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines();

                image.Settings.SetDefines(defines);

                Assert.AreEqual(null, defines.ClusterFit);
                Assert.AreEqual(null, image.Settings.GetDefine(MagickFormat.Dds, "cluster-fit"));
            }
        }
コード例 #7
0
        public void MipMapsFromCollection_NotSet_DefineIsNotSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines();

                image.Settings.SetDefines(defines);

                Assert.AreEqual(null, defines.Mipmaps);
                Assert.AreEqual(null, image.Settings.GetDefine(MagickFormat.Dds, "mipmaps"));
            }
        }
コード例 #8
0
        public void Compression_IsSet_DefineIsSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines
                {
                    Compression = DdsCompression.Dxt1,
                };

                image.Settings.SetDefines(defines);

                Assert.AreEqual("Dxt1", image.Settings.GetDefine(MagickFormat.Dds, "compression"));
            }
        }
コード例 #9
0
            public void ShouldSetTheDefine()
            {
                using (var image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        WeightByAlpha = false,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.Equal("false", image.Settings.GetDefine(MagickFormat.Dds, "weight-by-alpha"));
                }
            }
コード例 #10
0
        public void WeightByAlpha_IsSet_DefineIsSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines
                {
                    WeightByAlpha = false,
                };

                image.Settings.SetDefines(defines);

                Assert.AreEqual("False", image.Settings.GetDefine(MagickFormat.Dds, "weight-by-alpha"));
            }
        }
コード例 #11
0
        public void MipMaps_IsSet_DefineIsSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines
                {
                    Mipmaps = 2,
                };

                image.Settings.SetDefines(defines);

                Assert.AreEqual("2", image.Settings.GetDefine(MagickFormat.Dds, "mipmaps"));
            }
        }
コード例 #12
0
            public void ShouldSetTheDefine()
            {
                using (var image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        FastMipmaps = true,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.AreEqual("true", image.Settings.GetDefine(MagickFormat.Dds, "fast-mipmaps"));
                }
            }
コード例 #13
0
            public void ShouldSetTheDefine()
            {
                using (var image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        ClusterFit = true,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.Equal("true", image.Settings.GetDefine(MagickFormat.Dds, "cluster-fit"));
                }
            }
コード例 #14
0
            public void ShouldSetTheDefine()
            {
                using (var image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        Compression = DdsCompression.Dxt1,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.Equal("Dxt1", image.Settings.GetDefine(MagickFormat.Dds, "compression"));
                }
            }
コード例 #15
0
            public void ShouldSetTheDefine()
            {
                using (var image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        Mipmaps = 2,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.Equal("2", image.Settings.GetDefine(MagickFormat.Dds, "mipmaps"));
                }
            }
コード例 #16
0
        public void ClusterFit_IsSet_DefineIsSet()
        {
            using (IMagickImage image = new MagickImage())
            {
                var defines = new DdsWriteDefines
                {
                    ClusterFit = true,
                };

                image.Settings.SetDefines(defines);

                Assert.AreEqual("True", image.Settings.GetDefine(MagickFormat.Dds, "cluster-fit"));
            }
        }
コード例 #17
0
            public void ShouldSetTheDefine()
            {
                using (IMagickImage image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        Raw = true,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.AreEqual("True", image.Settings.GetDefine(MagickFormat.Dds, "raw"));
                }
            }
コード例 #18
0
            public void ShouldSetTheDefine()
            {
                using (IMagickImage image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        MipmapsFromCollection = true,
                        Mipmaps = 4, // this is ignored
                    };

                    image.Settings.SetDefines(defines);

                    Assert.AreEqual("fromlist", image.Settings.GetDefine(MagickFormat.Dds, "mipmaps"));
                }
            }
コード例 #19
0
            public void ShouldBeIgnoredWhenSetToFalse()
            {
                using (IMagickImage image = new MagickImage())
                {
                    var defines = new DdsWriteDefines
                    {
                        MipmapsFromCollection = false,
                        Mipmaps = 4,
                    };

                    image.Settings.SetDefines(defines);

                    Assert.AreEqual("4", image.Settings.GetDefine(MagickFormat.Dds, "mipmaps"));
                }
            }
コード例 #20
0
        public void Test_ClusterFit_Mipmaps_WeightByAlpha()
        {
            DdsWriteDefines defines = new DdsWriteDefines()
            {
                ClusterFit    = true,
                Mipmaps       = 0,
                WeightByAlpha = false,
            };

            using (MagickImage image = new MagickImage(Files.Builtin.Logo))
            {
                image.Settings.SetDefines(defines);

                Assert.AreEqual("True", image.Settings.GetDefine(MagickFormat.Dds, "cluster-fit"));
                Assert.AreEqual("0", image.Settings.GetDefine(MagickFormat.Dds, "mipmaps"));
                Assert.AreEqual("False", image.Settings.GetDefine(MagickFormat.Dds, "weight-by-alpha"));
            }
        }
コード例 #21
0
        public void Test_Compression()
        {
            DdsWriteDefines defines = new DdsWriteDefines()
            {
                Compression = DdsCompression.None
            };

            using (MagickImage input = new MagickImage(Files.Builtin.Logo))
            {
                using (MagickImage output = WriteDds(input))
                {
                    Assert.AreEqual(CompressionMethod.DXT1, output.CompressionMethod);
                }

                input.Settings.SetDefines(defines);

                using (MagickImage output = WriteDds(input))
                {
                    Assert.AreEqual(CompressionMethod.NoCompression, output.CompressionMethod);
                }
            }
        }