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


C# MagickImage.Trim方法代码示例

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


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

示例1: 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

示例2: ExecuteTrim

 private static void ExecuteTrim(MagickImage image)
 {
   image.Trim();
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:4,代码来源:MagickImage.cs

示例3: Draw

        public MagickImage Draw()
        {
            MainForm.ProgressStart("Rendering background ...");

            // Check which terrain file is used
            string texMpk = string.Format("{0}\\tex{1}.mpk", this.textureZoneDataDirectory, this.textureZoneId);
            string lodMpk = string.Format("{0}\\lod{1}.mpk", this.textureZoneDataDirectory, this.textureZoneId);

            // Get the tile dimension
            double tileWidth = 512.0;
            string tileTemplate = "";

            MPAK mpak = new MPAK();
            if (File.Exists(texMpk))
            {
                mpak.Load(texMpk);

                if (mpak.Files.Where(f => f.Name.ToLower() == "tex00-00.dds").Count() > 0)
                {
                    tileTemplate += "tex0{0}-0{1}.dds";
                    tileWidth = 512.0;
                }
            }

            if (string.IsNullOrEmpty(tileTemplate))
            {
                mpak.Load(lodMpk);

                if (mpak.Files.Where(f => f.Name.ToLower() == "lod00-00.dds").Count() > 0)
                {
                    tileTemplate += "lod0{0}-0{1}.dds";
                    tileWidth = 256.0;
                }
            }

            if (string.IsNullOrEmpty(tileTemplate))
            {
                MainForm.Log(string.Format("Zone {0}: No background textures found!", zoneConfiguration.ZoneId), MainForm.LogLevel.error);
                return null;
            }

            // original size
            double orginalWidth = tileWidth * 8;
            double resizeFactor = (double)zoneConfiguration.TargetMapSize / (double)orginalWidth; // 0 - 1

            MagickImage map = new MagickImage(Color.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize);

            int lastWidth = 0;
            int x = 0;
            for (int col = 0; col <= 7; col++)
            {
                int y = 0;
                for (int row = 0; row <= 7; row++)
                {
                    string filename = string.Format(tileTemplate, col, row);

                    using (MagickImage mapTile = new MagickImage(mpak.GetFile(filename).Data))
                    {
                        int newSize = Convert.ToInt32(mapTile.Width * resizeFactor);
                        mapTile.Resize(newSize, newSize);

                        map.Composite(mapTile, x, y, CompositeOperator.SrcOver);

                        // Calculate new y
                        y += mapTile.Height;
                        lastWidth = mapTile.Height;
                    }
                }

                x += lastWidth;

                int percent = 100 * col / 8;
                MainForm.ProgressUpdate(percent);
            }

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

            // Remove rounding fails
            map.Trim();

            // Flip if set
            if (this.flipX) map.Flop();
            if (this.flipY) map.Flip();

            // Sharpen (tested a lot, seems to be the best values)
            map.Sharpen(4, 3);

            MainForm.ProgressReset();

            return map;
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:91,代码来源:MapBackground.cs

示例4: Test_Trim

    public void Test_Trim()
    {
      using (MagickImage image = new MagickImage("xc:fuchsia", 50, 50))
      {
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 49, 49);

        image.Extent(100, 60, Gravity.Center, MagickColors.Gold);

        Assert.AreEqual(100, image.Width);
        Assert.AreEqual(60, image.Height);
        ColorAssert.AreEqual(MagickColors.Gold, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 50, 30);

        image.Trim();

        Assert.AreEqual(50, image.Width);
        Assert.AreEqual(50, image.Height);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 0, 0);
        ColorAssert.AreEqual(MagickColors.Fuchsia, image, 49, 49);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:22,代码来源:MagickImageTests.cs


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