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


C# MagickImage.Draw方法代码示例

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


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

示例1: Test_Drawables

    public void Test_Drawables()
    {
      Coordinate[] coordinates = new Coordinate[3];
      coordinates[0] = new Coordinate(0, 0);
      coordinates[1] = new Coordinate(50, 50);
      coordinates[2] = new Coordinate(99, 99);

      using (MagickImage image = new MagickImage(MagickColor.Transparent, 100, 100))
      {
        image.Draw(new DrawableAffine(0, 0, 1, 1, 2, 2));
        image.Draw(new DrawableArc(0, 0, 10, 10, 45, 90));
        image.Draw(new DrawableBezier(coordinates));
        image.Draw(new DrawableCircle(0, 0, 50, 50));
        image.Draw(new DrawableClipPath("foo"));
        image.Draw(new DrawableColor(0, 0, PaintMethod.Floodfill));

        using (MagickImage compositeImage = new MagickImage(new MagickColor("red"), 50, 50))
        {
          image.Draw(new DrawableCompositeImage(0, 0, compositeImage));
          image.Draw(new DrawableCompositeImage(0, 0, CompositeOperator.Over, compositeImage));
          image.Draw(new DrawableCompositeImage(new MagickGeometry(50, 50, 10, 10), compositeImage));
          image.Draw(new DrawableCompositeImage(new MagickGeometry(50, 50, 10, 10), CompositeOperator.Over, compositeImage));
        }

        image.Draw(new DrawableDashArray(new double[2] { 10, 20 }));
        image.Draw(new DrawableDashOffset(2));
        image.Draw(new DrawableDensity(97));
        image.Draw(new DrawableEllipse(10, 10, 4, 4, 0, 360));
        image.Draw(new DrawableFillOpacity(new Percentage(50)));
        image.Draw(new DrawableFillColor(Color.Red));
        image.Draw(new DrawableFont("Arial"));
        image.Draw(new DrawableGravity(Gravity.Center));
        image.Draw(new DrawableLine(20, 20, 40, 40));
        image.Draw(new DrawableMiterLimit(5));
        image.Draw(new DrawableOpacity(0, 0, PaintMethod.Floodfill));
        image.Draw(new DrawablePoint(60, 60));
        image.Draw(new DrawablePointSize(5));
        image.Draw(new DrawablePolygon(coordinates));
        image.Draw(new DrawablePolyline(coordinates));
        image.Draw(new DrawableRectangle(30, 30, 70, 70));
        image.Draw(new DrawableRotation(180));
        image.Draw(new DrawableRoundRectangle(50, 50, 30, 30, 70, 70));
        image.Draw(new DrawableScaling(15, 15));
        image.Draw(new DrawableSkewX(90));
        image.Draw(new DrawableSkewY(90));
        image.Draw(new DrawableStrokeAntialias(true));
        image.Draw(new DrawableStrokeColor(Color.Purple));
        image.Draw(new DrawableStrokeLineCap(LineCap.Square));
        image.Draw(new DrawableStrokeLineJoin(LineJoin.Bevel));
        image.Draw(new DrawableStrokeOpacity(new Percentage(80)));
        image.Draw(new DrawableStrokeWidth(4));
        image.Draw(new DrawableText(0, 60, "test"));
        image.Draw(new DrawableTextAntialias(true));
        image.Draw(new DrawableTextDecoration(TextDecoration.LineThrough));
        image.Draw(new DrawableTextDirection(TextDirection.RightToLeft));
        image.Draw(new DrawableTextInterlineSpacing(4));
        image.Draw(new DrawableTextInterwordSpacing(6));
        image.Draw(new DrawableTextKerning(2));
        image.Draw(new DrawableTextUnderColor(Color.Yellow));
        image.Draw(new DrawableTranslation(65, 65));
        image.Draw(new DrawableViewbox(0, 0, 100, 100));

        image.Draw(new DrawablePushClipPath("#1"), new DrawablePopClipPath());
        image.Draw(new DrawablePushPattern("test", 30, 30, 10, 10), new DrawablePopPattern());
        image.Draw(new DrawablePushGraphicContext(), new DrawablePopGraphicContext());
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:67,代码来源:DrawableTests.cs

示例2: Test_StrokeMiterLimit

    public void Test_StrokeMiterLimit()
    {
      using (MagickImage image = new MagickImage(MagickColors.SkyBlue, 100, 60))
      {
        Assert.AreEqual(10, image.Settings.StrokeMiterLimit);

        image.Settings.StrokeWidth = 5;
        image.Settings.StrokeColor = MagickColors.MediumSpringGreen;
        image.Settings.StrokeMiterLimit = 6;

        image.Draw(new DrawablePath(new PathMoveToAbs(65, 70), new PathLineToAbs(80, 20), new PathLineToAbs(95, 70)));

        ColorAssert.AreEqual(MagickColors.SkyBlue, image, 80, 18);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:MagickSettingsTests.cs

示例3: CreateImage

    private MagickImage CreateImage(int? density)
    {
      MagickImage image = new MagickImage(MagickColors.Purple, 500, 500);
      DrawableFontPointSize pointSize = new DrawableFontPointSize(20);
      DrawableText text = new DrawableText(250, 250, "Magick.NET");

      if (!density.HasValue)
        image.Draw(pointSize, text);
      else
        image.Draw(pointSize, new DrawableDensity(density.Value), text);

      image.Trim();

      return image;
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:DrawableDensityTests.cs

示例4: Test_Drawable

 public void Test_Drawable()
 {
   using (MagickImage image = new MagickImage(MagickColors.Red, 10, 10))
   {
     MagickColor yellow = MagickColors.Yellow;
     image.Draw(new DrawableFillColor(yellow), new DrawableRectangle(0, 0, 10, 10));
     ColorAssert.AreEqual(yellow, image, 5, 5);
   }
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:9,代码来源:MagickImageTests.cs

示例5: Test_DrawablePaths

    public void Test_DrawablePaths()
    {
      using (MagickImage image = new MagickImage(MagickColor.Transparent, 100, 100))
      {
        List<IPath> paths = new List<IPath>();
        paths.Add(new PathArcAbs(new PathArc(50, 50, 20, 20, 45, true, false)));
        paths.Add(new PathArcRel(new PathArc(10, 10, 5, 5, 40, false, true)));
        paths.Add(new PathClosePath());
        paths.Add(new PathCurvetoAbs(new PathCurveto(80, 80, 10, 10, 60, 60)));
        paths.Add(new PathCurvetoRel(new PathCurveto(30, 30, 60, 60, 90, 90)));
        paths.Add(new PathLinetoAbs(new Coordinate(70, 70)));
        paths.Add(new PathLinetoHorizontalAbs(20));
        paths.Add(new PathLinetoHorizontalRel(90));
        paths.Add(new PathLinetoRel(new Coordinate(0, 0)));
        paths.Add(new PathLinetoVerticalAbs(70));
        paths.Add(new PathLinetoVerticalRel(30));
        paths.Add(new PathMovetoAbs(new Coordinate(50, 50)));
        paths.Add(new PathMovetoRel(new Coordinate(20, 20)));
        paths.Add(new PathQuadraticCurvetoAbs(new PathQuadraticCurveto(70, 70, 30, 30)));
        paths.Add(new PathQuadraticCurvetoRel(new PathQuadraticCurveto(10, 10, 40, 40)));
        paths.Add(new PathSmoothCurvetoAbs(new Coordinate(0, 0), new Coordinate(30, 30)));
        paths.Add(new PathSmoothCurvetoRel(new Coordinate(60, 60), new Coordinate(10, 10)));
        paths.Add(new PathSmoothQuadraticCurvetoAbs(new Coordinate(50, 50)));
        paths.Add(new PathSmoothQuadraticCurvetoRel(new Coordinate(80, 80)));

        image.Draw(new DrawablePath(paths));
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:28,代码来源:DrawablePathTests.cs

示例6: Test_Draw

    public void Test_Draw()
    {
      using (MagickImage image = new MagickImage(MagickColors.Fuchsia, 100, 100))
      {
        image.Draw(new Drawables()
          .FillColor(MagickColors.Red)
          .Rectangle(10, 10, 90, 90));

        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 9, 9);
        ColorAssert.AreEqual(MagickColors.Red, image, 10, 10);
        ColorAssert.AreEqual(MagickColors.Red, image, 90, 90);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 91, 91);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:14,代码来源:DrawablesTests.cs

示例7: Test_BorderColor

    public void Test_BorderColor()
    {
      using (MagickImage image = new MagickImage(MagickColors.MediumTurquoise, 10, 10))
      {
        ColorAssert.AreEqual(new MagickColor("#df"), image.Settings.BorderColor);

        image.Settings.FillColor = MagickColors.Beige;
        image.Settings.BorderColor = MagickColors.MediumTurquoise;
        image.Extent(20, 20, Gravity.Center, MagickColors.Aqua);
        image.Draw(new DrawableAlpha(0, 0, PaintMethod.FillToBorder));

        ColorAssert.AreEqual(MagickColors.Beige, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.MediumTurquoise, image, 10, 10);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:MagickSettingsTests.cs

示例8: Test_Draw_Drawables

    public void Test_Draw_Drawables()
    {
      using (MagickImage image = new MagickImage(MagickColors.Green, 100, 10))
      {
        image.Draw(new Drawables()
          .StrokeColor(MagickColors.Red)
          .StrokeWidth(5)
          .Paths()
          .LineToRel(10, 2)
          .LineToRel(80, 4));

        ColorAssert.AreEqual(MagickColors.Green, image, 9, 5);
        ColorAssert.AreEqual(MagickColors.Red, image, 55, 5);
        ColorAssert.AreEqual(MagickColors.Green, image, 90, 2);
        ColorAssert.AreEqual(MagickColors.Green, image, 90, 9);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:17,代码来源:PathsTests.cs

示例9: Test_Draw_Paths

    public void Test_Draw_Paths()
    {
      using (MagickImage image = new MagickImage(MagickColors.Fuchsia, 100, 3))
      {
        image.Draw(new Paths()
          .LineToAbs(10, 1)
          .LineToAbs(90, 1));

        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 9, 1);

        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 10, 0);
        ColorAssert.AreEqual(MagickColors.Black, image, 10, 1);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 10, 2);

        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 90, 0);
        ColorAssert.AreEqual(MagickColors.Black, image, 90, 1);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 90, 2);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:19,代码来源:PathsTests.cs

示例10: Test_Drawable

 public void Test_Drawable()
 {
   using (MagickImage image = new MagickImage(Color.Red, 10, 10))
   {
     MagickColor yellow = Color.Yellow;
     image.Draw(new DrawableFillColor(yellow), new DrawableRectangle(0, 0, 10, 10));
     Test_Pixel_Equal(image, 5, 5, yellow);
   }
 }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:9,代码来源:MagickImageTests.cs

示例11: Test_Drawables_Exceptions

    public void Test_Drawables_Exceptions()
    {
      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawableBezier();
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableBezier(null);
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawableBezier(new PointD[] { });
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableClipPath(null);
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawableClipPath("");
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableComposite(null, new MagickImage(Files.Builtin.Logo));
      });

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

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableFillColor(null);
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableFont(null);
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawableFont("");
      });

      ExceptionAssert.Throws<MagickDrawErrorException>(delegate ()
      {
        using (MagickImage image = new MagickImage(Files.Builtin.Wizard))
        {
          image.Draw(new DrawableFillPatternUrl("#fail"));
        }
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawablePolygon(new PointD[] { new PointD(0, 0) });
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawablePolyline(new PointD[] { new PointD(0, 0), new PointD(0, 0) });
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableStrokeColor(null);
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableText(0, 0, null);
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        new DrawableText(0, 0, "");
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        new DrawableTextEncoding(null);
      });
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:90,代码来源:DrawableTests.cs

示例12: DebugRiver

        private void DebugRiver(int index, WaterConfiguration river, List<Coordinate> riverCoordinates)
        {
            string debugFilename = string.Format("{0}\\debug\\rivers\\{1}_{2}_{3}.jpg", System.Windows.Forms.Application.StartupPath, zoneConfiguration.ZoneId, index, river.Name);

            if (index == 0)
            {
                DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(debugFilename));
                if (di.Exists) di.EnumerateFiles().ToList().ForEach(f => f.Delete());
                else di.Create();
            }

            using (MagickImage debugRiver = new MagickImage(MagickColor.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
            {
                debugRiver.BackgroundColor = Color.White;
                debugRiver.FillColor = new MagickColor(0, 0, ushort.MaxValue, 256 * 128);

                double resizeFactor = zoneConfiguration.TargetMapSize / zoneConfiguration.Heightmap.Heightmap.Width;

                DrawablePolygon poly = new DrawablePolygon(riverCoordinates);
                debugRiver.Draw(poly);

                List<Coordinate> orginalCoords = river.GetCoordinates();
                for (int i = 0; i < riverCoordinates.Count(); i++)
                {
                    double x, y;

                    if (riverCoordinates[i].X > zoneConfiguration.TargetMapSize / 2) x = riverCoordinates[i].X - 15;
                    else x = riverCoordinates[i].X + 1;

                    if (riverCoordinates[i].Y < zoneConfiguration.TargetMapSize / 2) y = riverCoordinates[i].Y + 15;
                    else y = riverCoordinates[i].Y - 1;

                    debugRiver.FontPointsize = 14.0;
                    debugRiver.FillColor = Color.Black;
                    DrawableText text = new DrawableText(x, y, string.Format("{0} ({1}/{2})", i, orginalCoords[i].X, orginalCoords[i].Y));
                    debugRiver.Draw(text);
                }

                debugRiver.Quality = 100;
                debugRiver.Write(debugFilename);
            }
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:42,代码来源:MapWater.cs

示例13: Draw

        public void Draw(MagickImage map)
        {
            MainForm.ProgressStart("Rendering water ...");

            using (PixelCollection heightmapPixels = zoneConfiguration.Heightmap.HeightmapScaled.GetReadOnlyPixels())
            {
                using (MagickImage water = new MagickImage(MagickColor.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
                {
                    int progressCounter = 0;

                    foreach (WaterConfiguration river in m_waterAreas)
                    {
                        MainForm.Log(river.Name + "...", MainForm.LogLevel.notice);

                        MagickColor fillColor;
                        if (m_useClientColors) fillColor = river.Color;
                        else fillColor = m_waterColor;
                        //water.FillColor = fillColor;

                        // Get the river coordinates and scale them to the targets size
                        List<Coordinate> riverCoordinates = river.GetCoordinates().Select(c => new Coordinate(c.X * zoneConfiguration.MapScale, c.Y * zoneConfiguration.MapScale)).ToList();

                        // Texture
                        using (MagickImage texture = new MagickImage((river.Type.ToLower() == "lava") ? GetLavaTexture() : GetWateryTexture()))
                        {
                            using (MagickImage pattern = new MagickImage(fillColor, texture.Width, texture.Height))
                            {
                                texture.Composite(pattern, 0, 0, CompositeOperator.DstIn);
                                texture.Composite(pattern, 0, 0, CompositeOperator.ColorDodge);

                                water.FillPattern = texture;
                                DrawablePolygon poly = new DrawablePolygon(riverCoordinates);
                                water.Draw(poly);
                            }
                        }

                        // get the min/max and just process them
                        int minX = Convert.ToInt32(riverCoordinates.Min(m => m.X)) - 10;
                        int maxX = Convert.ToInt32(riverCoordinates.Max(m => m.X)) + 10;
                        int minY = Convert.ToInt32(riverCoordinates.Min(m => m.Y)) - 10;
                        int maxY = Convert.ToInt32(riverCoordinates.Max(m => m.Y)) + 10;

                        using (WritablePixelCollection riverPixelCollection = water.GetWritablePixels())
                        {
                            for (int x = minX; x < maxX; x++)
                            {
                                if (x < 0) continue;
                                if (x >= zoneConfiguration.TargetMapSize) continue;

                                for (int y = minY; y < maxY; y++)
                                {
                                    if (y < 0) continue;
                                    if (y >= zoneConfiguration.TargetMapSize) continue;

                                    ushort pixelHeight = heightmapPixels.GetPixel(x, y).GetChannel(0);
                                    if (pixelHeight > river.Height)
                                    {
                                        Pixel newPixel = new Pixel(x, y, new ushort[] { 0, 0, 0, ushort.MinValue });
                                        riverPixelCollection.Set(newPixel);
                                    }
                                }
                            }
                        }

                        if (debug)
                        {
                            DebugRiver(progressCounter, river, riverCoordinates);
                        }

                        int percent = 100 * progressCounter / m_waterAreas.Count();
                        MainForm.ProgressUpdate(percent);
                        progressCounter++;
                    }

                    MainForm.ProgressStartMarquee("Merging...");

                    if (WaterTransparency != 0)
                    {
                        water.Alpha(AlphaOption.Set);
                        double divideValue = 100.0 / (100.0 - WaterTransparency);
                        water.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                    }

                    water.Blur();
                    map.Composite(water, 0, 0, CompositeOperator.SrcOver);
                }
            }

            MainForm.ProgressReset();
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:90,代码来源:MapWater.cs

示例14: Test_FillRule

    public void Test_FillRule()
    {
      using (MagickImage image = new MagickImage(MagickColors.SkyBlue, 100, 60))
      {
        Assert.AreEqual(FillRule.EvenOdd, image.Settings.FillRule);

        image.Settings.FillRule = FillRule.Nonzero;
        image.Settings.FillColor = MagickColors.White;
        image.Settings.StrokeColor = MagickColors.Black;
        image.Draw(new DrawablePath(
          new PathMoveToAbs(40, 10),
          new PathLineToAbs(20, 20),
          new PathLineToAbs(70, 50),
          new PathClose(),
          new PathMoveToAbs(20, 40),
          new PathLineToAbs(70, 40),
          new PathLineToAbs(90, 10),
          new PathClose()
        ));

        ColorAssert.AreEqual(MagickColors.White, image, 50, 30);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:23,代码来源:MagickSettingsTests.cs

示例15: Test_Composite_ChangeMask

    public void Test_Composite_ChangeMask()
    {
      using (MagickImage background = new MagickImage("xc:red", 100, 100))
      {
        background.BackgroundColor = Color.White;
        background.Extent(200, 100);

        IDrawable[] drawables = new IDrawable[]
        {
          new DrawablePointSize(50),
          new DrawableText(135, 70, "X")
        };

        using (MagickImage image = background.Clone())
        {
          image.Draw(drawables);
          image.Composite(background, Gravity.Center, CompositeOperator.ChangeMask);

          using (MagickImage result = new MagickImage(MagickColor.Transparent, 200, 100))
          {
            result.Draw(drawables);
            Assert.AreEqual(0.073, result.Compare(image, ErrorMetric.RootMeanSquared), 0.001);
          }
        }
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:26,代码来源:MagickImageTests.cs


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