当前位置: 首页>>代码示例>>C#>>正文


C# MagickImage.Level方法代码示例

本文整理汇总了C#中ImageMagick.MagickImage.Level方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Level方法的具体用法?C# MagickImage.Level怎么用?C# MagickImage.Level使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageMagick.MagickImage的用法示例。


在下文中一共展示了MagickImage.Level方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteLevel

 private void ExecuteLevel(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "blackPoint")
       arguments["blackPoint"] = Variables.GetValue<QuantumType>(attribute);
     else if (attribute.Name == "blackPointPercentage")
       arguments["blackPointPercentage"] = Variables.GetValue<Percentage>(attribute);
     else if (attribute.Name == "channels")
       arguments["channels"] = Variables.GetValue<Channels>(attribute);
     else if (attribute.Name == "gamma")
       arguments["gamma"] = Variables.GetValue<double>(attribute);
     else if (attribute.Name == "whitePoint")
       arguments["whitePoint"] = Variables.GetValue<QuantumType>(attribute);
     else if (attribute.Name == "whitePointPercentage")
       arguments["whitePointPercentage"] = Variables.GetValue<Percentage>(attribute);
   }
   if (OnlyContains(arguments, "blackPoint", "whitePoint"))
     image.Level((QuantumType)arguments["blackPoint"], (QuantumType)arguments["whitePoint"]);
   else if (OnlyContains(arguments, "blackPoint", "whitePoint", "channels"))
     image.Level((QuantumType)arguments["blackPoint"], (QuantumType)arguments["whitePoint"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "blackPoint", "whitePoint", "gamma"))
     image.Level((QuantumType)arguments["blackPoint"], (QuantumType)arguments["whitePoint"], (double)arguments["gamma"]);
   else if (OnlyContains(arguments, "blackPoint", "whitePoint", "gamma", "channels"))
     image.Level((QuantumType)arguments["blackPoint"], (QuantumType)arguments["whitePoint"], (double)arguments["gamma"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "blackPointPercentage", "whitePointPercentage"))
     image.Level((Percentage)arguments["blackPointPercentage"], (Percentage)arguments["whitePointPercentage"]);
   else if (OnlyContains(arguments, "blackPointPercentage", "whitePointPercentage", "channels"))
     image.Level((Percentage)arguments["blackPointPercentage"], (Percentage)arguments["whitePointPercentage"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "blackPointPercentage", "whitePointPercentage", "gamma"))
     image.Level((Percentage)arguments["blackPointPercentage"], (Percentage)arguments["whitePointPercentage"], (double)arguments["gamma"]);
   else if (OnlyContains(arguments, "blackPointPercentage", "whitePointPercentage", "gamma", "channels"))
     image.Level((Percentage)arguments["blackPointPercentage"], (Percentage)arguments["whitePointPercentage"], (double)arguments["gamma"], (Channels)arguments["channels"]);
   else
     throw new ArgumentException("Invalid argument combination for 'level', allowed combinations are: [blackPoint, whitePoint] [blackPoint, whitePoint, channels] [blackPoint, whitePoint, gamma] [blackPoint, whitePoint, gamma, channels] [blackPointPercentage, whitePointPercentage] [blackPointPercentage, whitePointPercentage, channels] [blackPointPercentage, whitePointPercentage, gamma] [blackPointPercentage, whitePointPercentage, gamma, channels]");
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:37,代码来源:MagickImage.cs

示例2: Test_Level

    public void Test_Level()
    {
      using (MagickImage first = new MagickImage(Files.MagickNETIconPNG))
      {
        first.Level(new Percentage(50.0), new Percentage(10.0));

        using (MagickImage second = new MagickImage(Files.MagickNETIconPNG))
        {
          Assert.AreNotEqual(first, second);
          Assert.AreNotEqual(first.Signature, second.Signature);

          second.Level((QuantumType)(Quantum.Max * 0.5), (QuantumType)(Quantum.Max * 0.1));

          Assert.AreEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));

          Assert.AreEqual(first, second);
          Assert.AreEqual(first.Signature, second.Signature);
        }
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:20,代码来源:MagickImageTests.cs

示例3: DrawImage

        private void DrawImage(MagickImage overlay, DrawableFixture fixture)
        {
            //MainForm.Log(string.Format("Image: {0} ({1}) ...", fixture.Name, fixture.NifName), MainForm.LogLevel.notice);
            string fileName = System.IO.Path.GetFileNameWithoutExtension(fixture.NifName);
            string defaultTree = "elm1";

            // Load default tree
            if (!m_modelImages.ContainsKey(defaultTree))
            {
                string defaultTreeImage = string.Format("{0}\\data\\prerendered\\trees\\{1}.png", System.Windows.Forms.Application.StartupPath, defaultTree);
                if (System.IO.File.Exists(defaultTreeImage))
                {
                    MagickImage treeImage = new MagickImage(defaultTreeImage);
                    treeImage.Blur();
                    m_modelImages.Add(defaultTree, treeImage);
                }
                else
                {
                    m_modelImages.Add(fileName, null);
                }
            }

            // TreeClusters are sets of trees in a specified arrangement
            // They need to be drawe separately
            if (fixture.IsTreeCluster)
            {
                DrawTreeCluster(overlay, fixture);
                return;
            }

            // Load model image
            if (!m_modelImages.ContainsKey(fileName))
            {
                string objectImageFile = string.Format("{0}\\data\\prerendered\\objects\\{1}.png", System.Windows.Forms.Application.StartupPath, fileName);
                if (fixture.IsTree) objectImageFile = string.Format("{0}\\data\\prerendered\\trees\\{1}.png", System.Windows.Forms.Application.StartupPath, fileName);

                if (System.IO.File.Exists(objectImageFile))
                {
                    MagickImage objectImage = new MagickImage(objectImageFile);
                    if(fixture.IsTree) objectImage.Blur();
                    m_modelImages.Add(fileName, objectImage);
                }
                else
                {
                    if (fixture.IsTree)
                    {
                        MainForm.Log(string.Format("Can not find image for tree {0} ({1}), using default tree", fixture.Name, fixture.NifName), MainForm.LogLevel.warning);
                        m_modelImages.Add(fileName, m_modelImages[defaultTree]);
                    }
                    else m_modelImages.Add(fileName, null);
                }
            }

            // Draw the image
            if (m_modelImages.ContainsKey(fileName) && m_modelImages[fileName] != null)
            {
                NifRow orginalNif = FixturesLoader.NifRows.Where(n => n.NifId == fixture.FixtureRow.NifId).FirstOrDefault();
                if (orginalNif == null)
                {
                    MainForm.Log(string.Format("Error with imaged nif ({0})!", fixture.FixtureRow.TextualName), MainForm.LogLevel.warning);
                }

                System.Drawing.SizeF objectSize = orginalNif.GetSize(0, 0);

                // The final image
                using (MagickImage modelImage = new MagickImage(MagickColor.Transparent, fixture.CanvasWidth, fixture.CanvasHeight))
                {
                    // Place the replacing image
                    using (MagickImage newModelImage = m_modelImages[fileName].Clone())
                    {
                        newModelImage.BackgroundColor = MagickColor.Transparent;

                        double scaleWidthToTreeImage = objectSize.Width / newModelImage.Width;
                        double scaleHeightToTreeImage = objectSize.Height / newModelImage.Height;
                        int width = Convert.ToInt32(newModelImage.Width * scaleWidthToTreeImage * fixture.Scale);
                        int height = Convert.ToInt32(newModelImage.Height * scaleHeightToTreeImage * fixture.Scale);

                        // Resize to new size
                        newModelImage.FilterType = FilterType.Gaussian;
                        newModelImage.VirtualPixelMethod = VirtualPixelMethod.Transparent;
                        newModelImage.Resize(width, height);

                        // Rotate the image
                        //newModelImage.Rotate(fixture.FixtureRow.A * -1 * fixture.FixtureRow.AxisZ3D);
                        newModelImage.Rotate((360d * fixture.FixtureRow.AxisZ3D - fixture.FixtureRow.A) * -1);

                        // Place in center of modelImage
                        modelImage.Composite(newModelImage, Gravity.Center, CompositeOperator.SrcOver);
                    }

                    // Draw the shaped model if wanted
                    if (fixture.RendererConf.HasLight)
                    {
                        using (MagickImage modelShaped = new MagickImage(MagickColor.Transparent, fixture.CanvasWidth, fixture.CanvasHeight))
                        {
                            foreach (DrawableElement drawableElement in fixture.DrawableElements)
                            {
                                var light = 1 - drawableElement.lightning;
                                modelShaped.FillColor = new MagickColor(
                                    Convert.ToUInt16(ushort.MaxValue * light),
//.........这里部分代码省略.........
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:101,代码来源:MapFixtures.cs

示例4: Test_Level

    public void Test_Level()
    {
      using (MagickImage first = new MagickImage(Files.MagickNETIconPNG))
      {
        first.Level(new Percentage(50.0), new Percentage(10.0));

        using (MagickImage second = new MagickImage(Files.MagickNETIconPNG))
        {
          Assert.AreNotEqual(first, second);
          Assert.AreNotEqual(first.Signature, second.Signature);

          QuantumType fifty = (QuantumType)(Quantum.Max * 0.5);
          QuantumType ten = (QuantumType)(Quantum.Max * 0.1);
          second.Level(fifty, ten, Channels.Red);
          second.Level(fifty, ten, Channels.Green | Channels.Blue);
          second.Level(fifty, ten, Channels.Alpha);

          Assert.AreEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));

          Assert.AreEqual(first, second);
          Assert.AreEqual(first.Signature, second.Signature);
        }
      }

      using (MagickImage first = new MagickImage(Files.MagickNETIconPNG))
      {
        first.InverseLevel(new Percentage(50.0), new Percentage(10.0));

        using (MagickImage second = new MagickImage(Files.MagickNETIconPNG))
        {
          Assert.AreNotEqual(first, second);
          Assert.AreNotEqual(first.Signature, second.Signature);

          QuantumType fifty = (QuantumType)(Quantum.Max * 0.5);
          QuantumType ten = (QuantumType)(Quantum.Max * 0.1);
          second.InverseLevel(fifty, ten, Channels.Red);
          second.InverseLevel(fifty, ten, Channels.Green | Channels.Blue);
          second.InverseLevel(fifty, ten, Channels.Alpha);

          Assert.AreEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));

          Assert.AreEqual(first, second);
          Assert.AreEqual(first.Signature, second.Signature);
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:46,代码来源:MagickImageTests.cs


注:本文中的ImageMagick.MagickImage.Level方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。