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


C# ImageMagick.MagickImageCollection类代码示例

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


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

示例1: CreateAnimatedGif

    public static void CreateAnimatedGif()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        // Add first image and set the animation delay to 100ms
        collection.Add(SampleFiles.SnakewarePng);
        collection[0].AnimationDelay = 100;

        // Add second image, set the animation delay to 100ms and flip the image
        collection.Add(SampleFiles.SnakewarePng);
        collection[1].AnimationDelay = 100;
        collection[1].Flip();

        // Optionally reduce colors
        QuantizeSettings settings = new QuantizeSettings();
        settings.Colors = 256;
        collection.Quantize(settings);

        // Optionally optimize the images (images should have the same size).
        collection.Optimize();

        // Save gif
        collection.Write(SampleFiles.OutputDirectory + "Snakeware.Animated.gif");
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:25,代码来源:CombiningImages.cs

示例2: Test_Collection_Read

    public void Test_Collection_Read()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        MagickReadSettings settings = new MagickReadSettings();
        settings.Density = new Density(150);

        collection.Read(Files.RoseSparkleGIF, settings);

        Assert.AreEqual(150, collection[0].Density.X);

        settings = new MagickReadSettings();
        settings.FrameIndex = 1;

        collection.Read(Files.RoseSparkleGIF, settings);

        Assert.AreEqual(1, collection.Count);

        settings = new MagickReadSettings();
        settings.FrameIndex = 1;
        settings.FrameCount = 2;

        collection.Read(Files.RoseSparkleGIF, settings);

        Assert.AreEqual(2, collection.Count);

        settings = null;
        collection.Read(Files.RoseSparkleGIF, settings);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:30,代码来源:MagickReadSettingsTests.cs

示例3: Exec

 public override void Exec()
 {
     //var pages = this.Beg;
     L.D("executing pdf2img by file({0}),destination format({1})", this.AsSrc, this.AsDstF);
     this.Cdl.add();
     var tf_base = Path.GetTempFileName();
     var tf = tf_base + Path.GetExtension(this.AsSrc);
     MagickImageCollection images = new MagickImageCollection();
     try
     {
         File.Copy(this.AsSrc, tf, true);
         this.Pdf2imgProc(images, tf, -1, 0);
     }
     catch (Exception e)
     {
         L.E(e, "executing pdf2img by file({0}),destination format({1}) fail with error->{2}", tf, this.AsDstF, e.Message);
         this.Result.Code = 500;
         this.Fails.Add(e);
     }
     try
     {
         File.Delete(tf);
         File.Delete(tf_base);
     }
     catch (Exception e)
     {
         L.W("executing pdf2img on delete temp file({0}) error->{1}", tf, e.Message);
     }
     this.Cdl.done();
     this.Cdl.wait();
     images.Dispose();
     L.D("executing pdf2img by file({0}),destination format({1}) done with pages({2}),fails({3})", this.AsSrc, this.AsDstF, this.Result.Count, this.Fails.Count);
 }
开发者ID:Centny,项目名称:cswf.doc,代码行数:33,代码来源:PdfCov.cs

示例4: Pdf2imgProc

 protected virtual int Pdf2imgProc(MagickImageCollection images, String pdf, int idx, int file_c)
 {
     images.Read(pdf, settings);
     int pages = images.Count;
     if (pages > this.MaxPage)
     {
         this.Result.Code = 413;
         L.D("executing pdf2img by file({0}),destination format({1}) fail with too large code({2}),count({3})",
             this.AsSrc, this.AsDstF, this.Result.Code, this.Result.Count);
         return 0;
     }
     if (idx < 0)
     {
         this.Total = new int[pages];
         this.Done = new int[pages];
         Util.set(this.Total, 1);
         Util.set(this.Done, 0);
     }
     else
     {
         this.Total[idx] = pages;
     }
     for (var i = 0; i < pages; i++)
     {
         this.Pdf2imgProc(images[i], idx, i, file_c);
     }
     return pages;
 }
开发者ID:Centny,项目名称:cswf.doc,代码行数:28,代码来源:PdfCov.cs

示例5: Test_Append

    public void Test_Append()
    {
      int width = 70;
      int height = 46;

      using (MagickImageCollection collection = new MagickImageCollection())
      {
        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.AppendHorizontally();
        });

        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.AppendVertically();
        });

        collection.Read(Files.RoseSparkleGIF);

        Assert.AreEqual(width, collection[0].Width);
        Assert.AreEqual(height, collection[0].Height);

        using (MagickImage image = collection.AppendHorizontally())
        {
          Assert.AreEqual(width * 3, image.Width);
          Assert.AreEqual(height, image.Height);
        }

        using (MagickImage image = collection.AppendVertically())
        {
          Assert.AreEqual(width, image.Width);
          Assert.AreEqual(height * 3, image.Height);
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:35,代码来源:MagickImageCollectionTests.cs

示例6: CombineScreenshot

        /// <summary>
        /// Combines the screenshots into one contiguous screenshot
        /// </summary>
        /// <param name="files">The files (images) to combine</param>
        /// <param name="e">For UX, an output progress message</param>
        public static void CombineScreenshot(FileSystemInfo[] files, WaitWindowEventArgs e)
        {
           

            string screenshotLocation = Path.Combine(Constants.CacheLocation, "temp.png");

            using (MagickImageCollection images = new MagickImageCollection())
            {
                // Add the first image
                var orderedFiles = files.OrderBy(f => f.CreationTime);
                foreach (FileSystemInfo file in orderedFiles)
                {
                    MagickImage first = new MagickImage(file.FullName);
                    e.Window.Message = "Obtaining Snapshots... Please Wait";
                    images.Add(first);
                }

                using (MagickImage result = images.AppendVertically())
                {
                    e.Window.Message = "Building Screenshot... Please Wait" + System.Environment.NewLine + "This can take a minute.";
                    try
                    {
                        result.Write(screenshotLocation);
                    } catch (MagickImageErrorException err)
                    {
                        Debug.WriteLine($"Error: {err}");
                    }
                   
                }
        
            }
        }
开发者ID:joe-williams-cccu,项目名称:OSIRTv2,代码行数:37,代码来源:ScreenshotHelper.cs

示例7: ConvertPDFTOneImage

    public static void ConvertPDFTOneImage()
    {
      MagickReadSettings settings = new MagickReadSettings();
      // Settings the density to 300 dpi will create an image with a better quality
      settings.Density = new PointD(300, 300);

      using (MagickImageCollection images = new MagickImageCollection())
      {
        // Add all the pages of the pdf file to the collection
        images.Read(SampleFiles.SnakewarePdf, settings);

        // Create new image that appends all the pages horizontally
        using (MagickImage horizontal = images.AppendHorizontally())
        {
          // Save result as a png
          horizontal.Write(SampleFiles.OutputDirectory + "Snakeware.horizontal.png");
        }

        // Create new image that appends all the pages horizontally
        using (MagickImage vertical = images.AppendVertically())
        {
          // Save result as a png
          vertical.Write(SampleFiles.OutputDirectory + "Snakeware.vertical.png");
        }
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:26,代码来源:ConvertPDF.cs

示例8: ConfigGA

        public override void ConfigGA(GeneticAlgorithm ga)
        {
            base.ConfigGA(ga);
            ga.MutationProbability = 0.4f;
            ga.TerminationReached += (sender, args) =>
            {
                using (var collection = new MagickImageCollection())
                {
                    var files = Directory.GetFiles(m_destFolder, "*.png");

                    foreach (var image in files)
                    {
                        collection.Add(image);
                        collection[0].AnimationDelay = 100;
                    }

                    var settings = new QuantizeSettings();
                    settings.Colors = 256;
                    collection.Quantize(settings);

                    collection.Optimize();
                    collection.Write(Path.Combine(m_destFolder, "result.gif"));
                }
            };
        }
开发者ID:mahmoud-samy-symbyo,项目名称:GeneticSharp,代码行数:25,代码来源:BitmapEqualitySampleController.cs

示例9: Test_Read

 private static void Test_Read(MagickImageCollection collection)
 {
   Assert.AreEqual(3, collection.Count);
   foreach (MagickImage image in collection)
   {
     Assert.AreEqual(70, image.Width);
     Assert.AreEqual(46, image.Height);
   }
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:9,代码来源:MagickImageCollectionTests.cs

示例10: Test_ToBitmap

    public void Test_ToBitmap()
    {
      using (MagickImageCollection collection = new MagickImageCollection(Files.RoseSparkleGIF))
      {
        Assert.AreEqual(3, collection.Count);

        Bitmap bitmap = collection.ToBitmap();
        Assert.IsNotNull(bitmap);
        Assert.AreEqual(3, bitmap.GetFrameCount(FrameDimension.Page));
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:MagickImageCollectionTests.cs

示例11: WriteAndCheckProfile

    private static void WriteAndCheckProfile(MagickImageCollection images, PsdWriteDefines defines, int expectedLength)
    {
      using (MemoryStream memStream = new MemoryStream())
      {
        images.Write(memStream, defines);

        memStream.Position = 0;
        images.Read(memStream);
        CheckProfile(images[1], expectedLength);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:PsdWriteDefinesTests.cs

示例12: CreatePallete

    private MagickImage CreatePallete()
    {
      using (MagickImageCollection images = new MagickImageCollection())
      {
        images.Add(new MagickImage(MagickColors.Red, 1, 1));
        images.Add(new MagickImage(MagickColors.Blue, 1, 1));
        images.Add(new MagickImage(MagickColors.Green, 1, 1));

        return images.AppendHorizontally();
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:MagickImageTests.cs

示例13: Test_Ping

    private static void Test_Ping(MagickImageCollection collection)
    {
      Assert.AreEqual(1, collection.Count);

      ExceptionAssert.Throws<InvalidOperationException>(delegate ()
      {
        collection[0].GetPixels();
      });

      ImageProfile profile = collection[0].Get8BimProfile();
      Assert.IsNotNull(profile);
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:12,代码来源:MagickImageCollectionTests.cs

示例14: Test_Collection_Exceptions

    public void Test_Collection_Exceptions()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        MagickReadSettings settings = new MagickReadSettings();
        settings.PixelStorage = new PixelStorageSettings();

        ExceptionAssert.Throws<ArgumentException>(delegate ()
        {
          collection.Read(Files.RoseSparkleGIF, settings);
        });
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:13,代码来源:PixelStorageSettingsTests.cs

示例15: CreatePDFFromTwoImages

    public static void CreatePDFFromTwoImages()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        // Add first page
        collection.Add(new MagickImage(SampleFiles.SnakewareJpg));
        // Add second page
        collection.Add(new MagickImage(SampleFiles.SnakewareJpg));

        // Create pdf file with two pages
        collection.Write(SampleFiles.OutputDirectory + "Snakeware.pdf");
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:13,代码来源:ConvertPDF.cs


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