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


C# MagickImage.Read方法代码示例

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


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

示例1: Test_Image_Read

		public void Test_Image_Read()
		{
			using (MagickImage image = new MagickImage())
			{
				MagickReadSettings settings = new MagickReadSettings();
				settings.Density = new MagickGeometry(300, 300);

				image.Read(Files.SnakewarePNG, settings);

				Assert.AreEqual(300, image.Density.Width);

				settings = null;
				image.Read(Files.ImageMagickJPG, settings);
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:15,代码来源:MagickReadSettingsTests.cs

示例2: Test_WithImage

		public void Test_WithImage()
		{
			using (MagickImage image = new MagickImage())
			{
				image.AddProfile(ColorProfile.USWebCoatedSWOP);
				ExceptionAssert.Throws<MagickResourceLimitErrorException>(delegate()
				{
					image.ColorSpace = ColorSpace.CMYK;
				});
				image.Read(Files.SnakewarePNG);

				ColorProfile profile = image.GetColorProfile();
				Assert.IsNull(profile);

				image.AddProfile(ColorProfile.SRGB);
				TestProfile(image.GetColorProfile(), "icc");
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:18,代码来源:ColorProfileTests.cs

示例3: Test_Image_Read

		public void Test_Image_Read()
		{
			MagickReadSettings settings = CreateSettings();

			using (MagickImage image = new MagickImage())
			{
				byte[] data = new byte[]
					{ 
						0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0xf0, 0x3f,
						0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0xf0, 0x3f,
						0, 0, 0, 0, 0, 0, 0, 0,
						0, 0, 0, 0, 0, 0, 0, 0, 
					};
				image.Read(data, settings);

				Assert.AreEqual(2, image.Width);
				Assert.AreEqual(1, image.Height);

				using (PixelCollection pixels = image.GetReadOnlyPixels())
				{
					Pixel pixel = pixels.GetPixel(0, 0);
					Assert.AreEqual(4, pixel.Channels);
					Assert.AreEqual(0, pixel.GetChannel(0));
					Assert.AreEqual(0, pixel.GetChannel(1));
					Assert.AreEqual(0, pixel.GetChannel(2));
					Assert.AreEqual(Quantum.Max, pixel.GetChannel(3));

					pixel = pixels.GetPixel(1, 0);
					Assert.AreEqual(4, pixel.Channels);
					Assert.AreEqual(0, pixel.GetChannel(0));
					Assert.AreEqual(Quantum.Max, pixel.GetChannel(1));
					Assert.AreEqual(0, pixel.GetChannel(2));
					Assert.AreEqual(0, pixel.GetChannel(3));

					ExceptionAssert.Throws<ArgumentException>(delegate()
					{
						pixels.GetPixel(0, 1);
					});
				}
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:45,代码来源:PixelStorageSettingsTests.cs

示例4: Test_Resize

		public void Test_Resize()
		{
			using (MagickImage image = new MagickImage())
			{
				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(new MagickGeometry(64, 64));
				Assert.AreEqual(64, image.Width);
				Assert.AreEqual(64, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(200);
				Assert.AreEqual(256, image.Width);
				Assert.AreEqual(256, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(32, 32);
				Assert.AreEqual(32, image.Width);
				Assert.AreEqual(32, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(new MagickGeometry("5x10!"));
				Assert.AreEqual(5, image.Width);
				Assert.AreEqual(10, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(new MagickGeometry("32x32<"));
				Assert.AreEqual(128, image.Width);
				Assert.AreEqual(128, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(new MagickGeometry("256x256<"));
				Assert.AreEqual(256, image.Width);
				Assert.AreEqual(256, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(new MagickGeometry("32x32>"));
				Assert.AreEqual(32, image.Width);
				Assert.AreEqual(32, image.Height);

				image.Read(Files.GraphicsMagickNETIconPNG);
				image.Resize(new MagickGeometry("256x256>"));
				Assert.AreEqual(128, image.Width);
				Assert.AreEqual(128, image.Height);

				Percentage percentage = new Percentage(-0.5);
				ExceptionAssert.Throws<ArgumentException>(delegate()
				{
					image.Resize(percentage);
				});
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:51,代码来源:MagickImageTests.cs

示例5: Test_Read

		public void Test_Read()
		{
			MagickImage image = new MagickImage();

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

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

			ExceptionAssert.Throws<ArgumentNullException>(delegate()
			{
				image.Read((Bitmap)null);
			});

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

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

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

			ExceptionAssert.Throws<ArgumentException>(delegate()
			{
				image.Read("png:" + Files.Missing);
			});

			image.Read(File.ReadAllBytes(Files.SnakewarePNG));

			using (Bitmap bitmap = new Bitmap(Files.SnakewarePNG))
			{
				image.Read(bitmap);
				Assert.AreEqual(MagickFormat.Png, image.Format);
			}

			using (Bitmap bitmap = new Bitmap(100, 100, PixelFormat.Format24bppRgb))
			{
				image.Read(bitmap);
				Assert.AreEqual(MagickFormat.Bmp, image.Format);
			}

			using (FileStream fs = File.OpenRead(Files.SnakewarePNG))
			{
				image.Read(fs);
			}

			image.Read(Files.SnakewarePNG);

			image.Read("rose:");

			image.Read(Files.RoseSparkleGIF);
			Assert.AreEqual("RoseSparkle.gif", Path.GetFileName(image.FileName));

			image.Read("png:" + Files.SnakewarePNG);
			MagickColor red = new MagickColor("red");

			image.Read(red, 50, 50);
			Assert.AreEqual(50, image.Width);
			Assert.AreEqual(50, image.Height);
			Test_Pixel(image, 10, 10, red);

			image.Read("xc:red", 50, 50);
			Assert.AreEqual(50, image.Width);
			Assert.AreEqual(50, image.Height);
			Test_Pixel(image, 5, 5, red);

			image.Dispose();

			ExceptionAssert.Throws<ObjectDisposedException>(delegate()
				{
					image.Read("logo:");
				});
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:85,代码来源:MagickImageTests.cs

示例6: Test_Extent

		public void Test_Extent()
		{
			using (MagickImage image = new MagickImage())
			{
				image.Read(Files.RedPNG);
				image.Resize(new MagickGeometry(100, 100));
				Assert.AreEqual(100, image.Width);
				Assert.AreEqual(33, image.Height);

				image.BackgroundColor = MagickColor.Transparent;
				image.Extent(100, 100, Gravity.Center);
				Assert.AreEqual(100, image.Width);
				Assert.AreEqual(100, image.Height);

				using (PixelCollection pixels = image.GetReadOnlyPixels())
				{
					Assert.IsTrue(pixels.GetPixel(0, 0).ToColor() == MagickColor.Transparent);
				}
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:20,代码来源:MagickImageTests.cs


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