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


C# MagickImageCollection.Read方法代码示例

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


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

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

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

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

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

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

示例6: Convert2Jpeg

        public void Convert2Jpeg(bool rotate = false)
        {
            try
            {
                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(_pdf.FullName, settings);

                    if (images.Count > 0 && images[0].Format == MagickFormat.Pdf)
                    {
                        _logger.InfoFormat("Handle {0}", _pdf.FullName);

                        int page = 1;
                        foreach (MagickImage image in images)
                        {
                            var newFileName = GetFilePageName(page) + ".jpg";

                            // Need page rotation?
                            if (rotate)
                                image.Rotate(90.0);

                            // Write page to file that contains the page number
                            image.Format = MagickFormat.Jpg;
                            image.CompressionMethod = CompressionMethod.JPEG;
                            image.Quality = 75;
                            image.Write(newFileName);

                            _logger.InfoFormat("-> {0}", newFileName);

                            // Writing to a specific format works the same as for a single image
                            page++;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
            }
        }
开发者ID:Hinni,项目名称:HinniSolutions.PdfToolkit,代码行数:47,代码来源:Converter.cs

示例7: SplitIco

 public int SplitIco(string icoFileName)
 {
     var fullName = Path.GetFullPath(icoFileName);
     var folder = Path.GetDirectoryName(fullName);
     var baseName = Path.GetFileNameWithoutExtension(fullName);
     using (var imageCollection = new MagickImageCollection())
     {
         imageCollection.Read(icoFileName);
         foreach (var image in imageCollection)
         {                    
             var pngFileName = baseName + "-" + image.Height + ".png";
             var pngFile = Path.Combine(folder, pngFileName);
             image.Write(pngFile);
         }
     }
     return 0;
 }
开发者ID:trondr,项目名称:NMultiTool,代码行数:17,代码来源:SplitIcoCommandProvider.cs

示例8: ConvertPdfToOneTif

		private static void ConvertPdfToOneTif()
		{
			// Log all events
			//MagickNET.SetLogEvents(LogEvents.All | LogEvents.Trace);
			// Set the log handler (all threads use the same handler)
			//MagickNET.Log += DetailedDebugInformationSamples.MagickNET_Log;

			string sampleDocsDirectory = @"E:\projects\ImageProcessing\sampledocs\";
			string sampleFile = "sample6.pdf";

			try
			{
				MagickReadSettings settings = new MagickReadSettings();
				settings.Density = new PointD(300, 300);

				using (MagickImageCollection images = new MagickImageCollection())
				{
					// Add all the pages of the source file to the collection
					images.Read(Path.Combine(sampleDocsDirectory, sampleFile), settings);

					//Show page count
					Console.WriteLine("page count for {0} {1}", sampleFile, images.Count);

					string baseFileName = Path.GetFileNameWithoutExtension(sampleFile);

					// Create new image that appends all the pages horizontally
					//using (MagickImage vertical = images.AppendVertically())
					//{
					//	vertical.CompressionMethod = CompressionMethod.Group4;
					//	Console.WriteLine("saving file: {0}", baseFileName + ".tif");
					//	vertical.Write(sampleDocsDirectory + baseFileName + ".tif");
					//}

					Console.WriteLine("saving file: {0}", baseFileName + ".tif");
					images.Write(sampleDocsDirectory + baseFileName + ".tif");
				}

			}
			catch (Exception ex)
			{
				Console.WriteLine("ConvertPdfToOneTif {0}", ex.Message);
			}
		}
开发者ID:dstringvc,项目名称:imageprocessing,代码行数:43,代码来源:Program.cs

示例9: Test_AdditionalInfo

    public void Test_AdditionalInfo()
    {

      using (MagickImageCollection images = new MagickImageCollection())
      {
        images.Read(Files.Coders.LayerStylesSamplePSD);

        CheckProfile(images[1], 264);

        var defines = new PsdWriteDefines()
        {
          AdditionalInfo = PsdAdditionalInfo.All
        };
        WriteAndCheckProfile(images, defines, 264);

        defines.AdditionalInfo = PsdAdditionalInfo.Selective;
        WriteAndCheckProfile(images, defines, 152);

        defines.AdditionalInfo = PsdAdditionalInfo.None;
        WriteAndCheckProfile(images, defines, 0);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:22,代码来源:PsdWriteDefinesTests.cs

示例10: ConvertPDFToMultipleImages

    public static void ConvertPDFToMultipleImages()
    {
      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);

        int page = 1;
        foreach (MagickImage image in images)
        {
          // Write page to file that contains the page number
          image.Write(SampleFiles.OutputDirectory + "Snakeware.Page" + page + ".png");
          // Writing to a specific format works the same as for a single image
          image.Format = MagickFormat.Ptif;
          image.Write(SampleFiles.OutputDirectory + "Snakeware.Page" + page + ".tif");
          page++;
        }
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:23,代码来源:ConvertPDF.cs

示例11: ConvertToGrayScale

        public void ConvertToGrayScale(string sourceFile, string targetFile)
        {
            using (MagickImageCollection images = new MagickImageCollection())
            {
                string newTargetFile = @"D:\Development\Magik\Images\NewTiffs\New.tif";
                MagickReadSettings settings = new MagickReadSettings();
                images.Read(sourceFile, settings);
                settings.FrameIndex = 0; // First page
                settings.FrameCount = images.Count; // Number of pages
                int count = images.Count;

                foreach (MagickImage image in images)
                {
                    image.ColorType = ColorType.Grayscale;
                    image.Quantize();

                    image.Write(newTargetFile + count.ToString() + ".tif");
                    ++count;
                }
            }

            Process proc = new Process
            {
                StartInfo = new ProcessStartInfo

                {

                    FileName = @"C:\Program Files (x86)\ImageMagick-6.8.6-Q8\convert.exe",
                    Arguments = @"D:\Development\Magik\Images\NewTiffs\*.tif D:\Development\Magik\Images\Combined\all-in-one.tif",
                    UseShellExecute = false,
                    RedirectStandardError = true,
                    CreateNoWindow = true
                }
            };

            proc.Start();
        }
开发者ID:rbrownin,项目名称:Image-Services,代码行数:37,代码来源:MagikImageTransformer.cs

示例12: Test_Warning

    public void Test_Warning()
    {
      int count = 0;
      EventHandler<WarningEventArgs> warningDelegate = delegate (object sender, WarningEventArgs arguments)
      {
        Assert.IsNotNull(sender);
        Assert.IsNotNull(arguments);
        Assert.IsNotNull(arguments.Message);
        Assert.IsNotNull(arguments.Exception);
        Assert.AreNotEqual("", arguments.Message);

        count++;
      };

      using (MagickImageCollection collection = new MagickImageCollection())
      {
        collection.Warning += warningDelegate;
        collection.Read(Files.EightBimTIF);

        Assert.AreNotEqual(0, count);

        int expectedCount = count;
        collection.Warning -= warningDelegate;
        collection.Read(Files.EightBimTIF);

        Assert.AreEqual(expectedCount, count);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:28,代码来源:MagickImageCollectionTests.cs

示例13: Test_ToBase64

    public void Test_ToBase64()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        Assert.AreEqual("", collection.ToBase64());

        collection.Read(Files.Builtin.Logo);
        Assert.AreEqual(1228800, collection.ToBase64(MagickFormat.Rgb).Length);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:10,代码来源:MagickImageCollectionTests.cs

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

示例15: Test_Read

    public void Test_Read()
    {
      MagickImageCollection collection = new MagickImageCollection();

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        collection.Read(new byte[0]);
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        collection.Read((byte[])null);
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        collection.Read((Stream)null);
      });

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        collection.Read((string)null);
      });

      ExceptionAssert.Throws<ArgumentException>(delegate ()
      {
        collection.Read(Files.Missing);
      });

      collection.Read(File.ReadAllBytes(Files.RoseSparkleGIF));
      Assert.AreEqual(3, collection.Count);

      using (FileStream fs = File.OpenRead(Files.RoseSparkleGIF))
      {
        collection.Read(fs);
        Assert.AreEqual(3, collection.Count);
      }

      collection.Read(Files.RoseSparkleGIF);
      Test_Read(collection);

      collection.Read(new FileInfo(Files.RoseSparkleGIF));

      collection.Dispose();
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:45,代码来源:MagickImageCollectionTests.cs


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