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


C# MagickImage.Scale方法代码示例

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


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

示例1: scale

 public static void scale(string image_path, string output_path, int width_mul = 150, int height_mul = 150)
 {
     using (MagickImage image = new MagickImage(image_path)) {
         image.Scale(new Percentage(width_mul), new Percentage(height_mul));
         image.Write(output_path);
     }
 }
开发者ID:Neonarg,项目名称:TempestNotifier,代码行数:7,代码来源:Image.cs

示例2: CreateScaledImage

 private void CreateScaledImage()
 {
     using (MagickImage image = new MagickImage(imagePath))
     {
         //TODO: Perhaps see what the original size is then scale based on that
         //Keeping it at 25% may "punish" those images that are barely over the limit
         image.Scale(new Percentage(25));
         image.Write(Constants.ScaledImgFile);
     }
 }
开发者ID:joe-williams-cccu,项目名称:OSIRTv2,代码行数:10,代码来源:CannotOpenImagePanel.cs

示例3: GenerateAnimationGIF

		/**
		 * 指定されたディレクトリ内にある画像からGIFアニメーションを生成する
		 * @param {String} コマ画像が入っているディレクトリのパス
		 * @return {Boolean} 成功した場合はtrue
		 */
		Boolean GenerateAnimationGIF(String tmpDir, String dstPath) {
			String[] files = Directory.GetFiles(tmpDir);
			if (files.Length == 0) return false;
			using (MagickImageCollection collection = new MagickImageCollection()) {
				MagickImage canvas = new MagickImage(files[files.Length - 1]);
				canvas.AnimationDelay = 250;
				canvas.Scale((int)(canvas.Width * 0.5), (int)(canvas.Height * 0.5));
				collection.Add(canvas);

				int perFrame = (int)Math.Ceiling(600.0 / files.Length);
				foreach (String file in files) {
					canvas = new MagickImage(file);
					canvas.AnimationDelay = perFrame;
					canvas.Scale((int)(canvas.Width * 0.5), (int)(canvas.Height * 0.5));
					collection.Add(canvas);
				}

				collection.Optimize();
				collection.Write(dstPath);
			};
			return true;
		}
开发者ID:manse,项目名称:LIP2GIF,代码行数:27,代码来源:Processor.cs

示例4: ExecuteScale

 private void ExecuteScale(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "geometry")
       arguments["geometry"] = Variables.GetValue<MagickGeometry>(attribute);
     else if (attribute.Name == "height")
       arguments["height"] = Variables.GetValue<Int32>(attribute);
     else if (attribute.Name == "percentage")
       arguments["percentage"] = Variables.GetValue<Percentage>(attribute);
     else if (attribute.Name == "percentageHeight")
       arguments["percentageHeight"] = Variables.GetValue<Percentage>(attribute);
     else if (attribute.Name == "percentageWidth")
       arguments["percentageWidth"] = Variables.GetValue<Percentage>(attribute);
     else if (attribute.Name == "width")
       arguments["width"] = Variables.GetValue<Int32>(attribute);
   }
   if (OnlyContains(arguments, "geometry"))
     image.Scale((MagickGeometry)arguments["geometry"]);
   else if (OnlyContains(arguments, "percentage"))
     image.Scale((Percentage)arguments["percentage"]);
   else if (OnlyContains(arguments, "percentageWidth", "percentageHeight"))
     image.Scale((Percentage)arguments["percentageWidth"], (Percentage)arguments["percentageHeight"]);
   else if (OnlyContains(arguments, "width", "height"))
     image.Scale((Int32)arguments["width"], (Int32)arguments["height"]);
   else
     throw new ArgumentException("Invalid argument combination for 'scale', allowed combinations are: [geometry] [percentage] [percentageWidth, percentageHeight] [width, height]");
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:29,代码来源:MagickImage.cs

示例5: Test_Scale

    public void Test_Scale()
    {
      using (MagickImage image = new MagickImage(Files.CirclePNG))
      {
        MagickColor color = Color.FromArgb(159, 255, 255, 255);
        using (PixelCollection pixels = image.GetReadOnlyPixels())
        {
          ColorAssert.AreEqual(color, pixels.GetPixel(image.Width / 2, image.Height / 2).ToColor());
        }

        image.Scale((Percentage)400);

        using (PixelCollection pixels = image.GetReadOnlyPixels())
        {
          ColorAssert.AreEqual(color, pixels.GetPixel(image.Width / 2, image.Height / 2).ToColor());
        }
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:18,代码来源:MagickImageTests.cs

示例6: Test_Scale

    public void Test_Scale()
    {
      using (MagickImage image = new MagickImage(Files.CirclePNG))
      {
        MagickColor color = MagickColor.FromRgba(255, 255, 255, 159);
        ColorAssert.AreEqual(color, image, image.Width / 2, image.Height / 2);

        image.Scale((Percentage)400);
        ColorAssert.AreEqual(color, image, image.Width / 2, image.Height / 2);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:MagickImageTests.cs

示例7: Test_LinearStretch

    public void Test_LinearStretch()
    {
      using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
      {
        image.Scale(100, 100);

        image.LinearStretch((Percentage)1, (Percentage)1);
        using (MemoryStream memStream = new MemoryStream())
        {
          image.Format = MagickFormat.Histogram;
          image.Write(memStream);
          memStream.Position = 0;

          using (MagickImage histogram = new MagickImage(memStream))
          {
#if Q8
            ColorAssert.AreEqual(MagickColors.Red, histogram, 66, 11);
            ColorAssert.AreEqual(MagickColors.Lime, histogram, 95, 122);
            ColorAssert.AreEqual(MagickColors.Blue, histogram, 204, 80);
#elif Q16 || Q16HDRI
            ColorAssert.AreEqual(MagickColors.Red, histogram, 34, 182);
            ColorAssert.AreEqual(MagickColors.Lime, histogram, 122, 193);
            ColorAssert.AreEqual(MagickColors.Blue, histogram, 210, 194);
#else
#error Not implemented!
#endif
          }
        }

        image.LinearStretch((Percentage)10, (Percentage)90);
        using (MemoryStream memStream = new MemoryStream())
        {
          image.Format = MagickFormat.Histogram;
          image.Write(memStream);
          memStream.Position = 0;

          using (MagickImage histogram = new MagickImage(memStream))
          {
#if Q8
            ColorAssert.AreEqual(MagickColors.Red, histogram, 103, 183);
            ColorAssert.AreEqual(MagickColors.Lime, histogram, 147, 188);
            ColorAssert.AreEqual(MagickColors.Blue, histogram, 194, 190);
#elif Q16 || Q16HDRI
            ColorAssert.AreEqual(MagickColors.Red, histogram, 221, 182);
            ColorAssert.AreEqual(MagickColors.Lime, histogram, 12, 183);
            ColorAssert.AreEqual(MagickColors.Blue, histogram, 45, 194);
#else
#error Not implemented!
#endif
          }
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:53,代码来源:MagickImageTests.cs


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