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


C# MagickImage.CopyPixels方法代码示例

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


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

示例1: ExecuteCopyPixels

 private void ExecuteCopyPixels(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "channels")
       arguments["channels"] = Variables.GetValue<Channels>(attribute);
     else if (attribute.Name == "geometry")
       arguments["geometry"] = Variables.GetValue<MagickGeometry>(attribute);
     else if (attribute.Name == "offset")
       arguments["offset"] = Variables.GetValue<PointD>(attribute);
     else if (attribute.Name == "x")
       arguments["x"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "y")
       arguments["y"] = Variables.GetValue<Int32>(attribute);
   }
   foreach (XmlElement elem in element.SelectNodes("*"))
   {
     arguments[elem.Name] = CreateMagickImage(elem);
   }
   if (OnlyContains(arguments, "source"))
     image.CopyPixels((MagickImage)arguments["source"]);
   else if (OnlyContains(arguments, "source", "channels"))
     image.CopyPixels((MagickImage)arguments["source"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "source", "geometry"))
     image.CopyPixels((MagickImage)arguments["source"], (MagickGeometry)arguments["geometry"]);
   else if (OnlyContains(arguments, "source", "geometry", "channels"))
     image.CopyPixels((MagickImage)arguments["source"], (MagickGeometry)arguments["geometry"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "source", "geometry", "offset"))
     image.CopyPixels((MagickImage)arguments["source"], (MagickGeometry)arguments["geometry"], (PointD)arguments["offset"]);
   else if (OnlyContains(arguments, "source", "geometry", "offset", "channels"))
     image.CopyPixels((MagickImage)arguments["source"], (MagickGeometry)arguments["geometry"], (PointD)arguments["offset"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "source", "geometry", "x", "y"))
     image.CopyPixels((MagickImage)arguments["source"], (MagickGeometry)arguments["geometry"], (Int32)arguments["x"], (Int32)arguments["y"]);
   else if (OnlyContains(arguments, "source", "geometry", "x", "y", "channels"))
     image.CopyPixels((MagickImage)arguments["source"], (MagickGeometry)arguments["geometry"], (Int32)arguments["x"], (Int32)arguments["y"], (Channels)arguments["channels"]);
   else
     throw new ArgumentException("Invalid argument combination for 'copyPixels', allowed combinations are: [source] [source, channels] [source, geometry] [source, geometry, channels] [source, geometry, offset] [source, geometry, offset, channels] [source, geometry, x, y] [source, geometry, x, y, channels]");
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:39,代码来源:MagickImage.cs

示例2: Test_CopyPixels

    public void Test_CopyPixels()
    {
      using (MagickImage source = new MagickImage(Color.White, 100, 100))
      {
        using (MagickImage destination = new MagickImage(Color.Black, 50, 50))
        {
          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(51, 50), new Coordinate(0, 0));
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(50, 51), new Coordinate(0, 0));
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(50, 50), new Coordinate(1, 0));
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(50, 50), new Coordinate(0, 1));
          });

          destination.CopyPixels(source, new MagickGeometry(25, 25), new Coordinate(25, 25));

          Test_Pixel_Equal(destination, 0, 0, Color.Black);
          Test_Pixel_Equal(destination, 24, 24, Color.Black);
          Test_Pixel_Equal(destination, 25, 25, Color.White);
          Test_Pixel_Equal(destination, 49, 49, Color.White);
        }
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:35,代码来源:MagickImageTests.cs

示例3: ExecuteCopyPixels

 private void ExecuteCopyPixels(XmlElement element, MagickImage image)
 {
   MagickImage source_ = CreateMagickImage(element["source"]);
   MagickGeometry geometry_ = Variables.GetValue<MagickGeometry>(element, "geometry");
   Coordinate offset_ = CreateCoordinate(element["offset"]);
   image.CopyPixels(source_, geometry_, offset_);
 }
开发者ID:levesque,项目名称:Magick.NET,代码行数:7,代码来源:MagickImage.cs

示例4: Test_CopyPixels

    public void Test_CopyPixels()
    {
      using (MagickImage source = new MagickImage(MagickColors.White, 100, 100))
      {
        using (MagickImage destination = new MagickImage(MagickColors.Black, 50, 50))
        {
          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(null);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(null, Channels.Red);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(source, null);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(source, null, Channels.Green);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(source, null, 0, 0);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(source, null, 0, 0, Channels.Green);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(null, new MagickGeometry(10, 10));
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(null, new MagickGeometry(10, 10), Channels.Black);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(null, new MagickGeometry(10, 10), 0, 0);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            destination.CopyPixels(null, new MagickGeometry(10, 10), 0, 0, Channels.Black);
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(51, 50), new PointD(0, 0));
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(50, 51), new PointD(0, 0));
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(50, 50), 1, 0);
          });

          ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
          {
            destination.CopyPixels(source, new MagickGeometry(50, 50), new PointD(0, 1));
          });

          destination.CopyPixels(source, new MagickGeometry(25, 25), 25, 25);

          ColorAssert.AreEqual(MagickColors.Black, destination, 0, 0);
          ColorAssert.AreEqual(MagickColors.Black, destination, 24, 24);
          ColorAssert.AreEqual(MagickColors.White, destination, 25, 25);
          ColorAssert.AreEqual(MagickColors.White, destination, 49, 49);

          destination.CopyPixels(source, new MagickGeometry(25, 25), 0, 25, Channels.Green);

          ColorAssert.AreEqual(MagickColors.Black, destination, 0, 0);
          ColorAssert.AreEqual(MagickColors.Black, destination, 24, 24);
          ColorAssert.AreEqual(MagickColors.White, destination, 25, 25);
          ColorAssert.AreEqual(MagickColors.White, destination, 49, 49);
          ColorAssert.AreEqual(MagickColors.Lime, destination, 0, 25);
          ColorAssert.AreEqual(MagickColors.Lime, destination, 24, 49);
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:94,代码来源:MagickImageTests.cs


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