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


C# MagickImage.GetReadOnlyPixels方法代码示例

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


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

示例1: Test_Pixel

		//===========================================================================================
		private static void Test_Pixel(MagickImage image, int x, int y, MagickColor color)
		{
			using (PixelCollection collection = image.GetReadOnlyPixels())
			{
				ColorAssert.AreEqual(color, collection.GetPixel(x, y));
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:MagickImageTests.cs

示例2: Test_IEnumerable

		public void Test_IEnumerable()
		{
			using (MagickImage image = new MagickImage(Color.Red, 5, 10))
			{
				PixelCollection pixels = image.GetReadOnlyPixels();
				Assert.AreEqual(50, pixels.Count());
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:PixelCollectionTests.cs

示例3: Test_Dimensions

		public void Test_Dimensions()
		{
			using (MagickImage image = new MagickImage(Color.Red, 5, 10))
			{
				using (PixelCollection pixels = image.GetReadOnlyPixels())
				{
					Assert.AreEqual(5, pixels.Width);
					Assert.AreEqual(10, pixels.Height);
					Assert.AreEqual(5 * 10 * pixels.Channels, pixels.GetValues().Length);
				}
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:12,代码来源:PixelCollectionTests.cs

示例4: Test_GetValue

		public void Test_GetValue()
		{
			using (MagickImage image = new MagickImage(Color.Red, 5, 10))
			{
				using (PixelCollection pixels = image.GetReadOnlyPixels())
				{
					var values = pixels.GetValue(0, 0);
					Assert.AreEqual(5, values.Length);

					MagickColor color = new MagickColor(values[0], values[1], values[2], values[3]);
					ColorAssert.AreEqual(Color.Red, color);
				}
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:14,代码来源:PixelCollectionTests.cs

示例5: Test_Set

		public void Test_Set()
		{
			using (MagickImage image = new MagickImage(Color.Red, 5, 10))
			{
				using (WritablePixelCollection pixels = image.GetWritablePixels())
				{
					ExceptionAssert.Throws<ArgumentNullException>(delegate()
					{
						pixels.Set((QuantumType[])null);
					});

					ExceptionAssert.Throws<ArgumentNullException>(delegate()
					{
						pixels.Set((Pixel)null);
					});

					ExceptionAssert.Throws<ArgumentNullException>(delegate()
					{
						pixels.Set((Pixel[])null);
					});

					Test_Set(pixels, new QuantumType[] { });
					Test_Set(pixels, new QuantumType[] { 0 });
					Test_Set(pixels, new QuantumType[] { 0, 0 });
					Test_Set(pixels, new QuantumType[] { 0, 0, 0 });

					pixels.Set(new QuantumType[] { 0, 0, 0, 0, 0 });
					Test_PixelColor(pixels, Color.Black);
					pixels.Write();
				}

				using (PixelCollection pixels = image.GetReadOnlyPixels())
				{
					Test_PixelColor(pixels, Color.Black);
				}

				using (WritablePixelCollection pixels = image.GetWritablePixels())
				{
					pixels.Set(new uint[] { 4294967295, 0, 0, 0, 0 });
					Test_PixelColor(pixels, Color.Red);
					pixels.Set(new ushort[] { 0, 0, 65535, 0, 0 });
					Test_PixelColor(pixels, Color.Blue);
					pixels.Set(new byte[] { 0, 255, 0, 0, 0 });
					Test_PixelColor(pixels, Color.Lime);
				}

				using (WritablePixelCollection pixels = image.GetWritablePixels())
				{
					for (int x = 0; x < pixels.Width; x++)
					{
						for (int y = 0; y < pixels.Height; y++)
						{
							pixels.Set(x, y, new QuantumType[] { 0, 0, 0, 0, 0 });
						}
					}
				}
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:58,代码来源:WritablePixelCollectionTests.cs

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

示例7: Test_Scale

		public void Test_Scale()
		{
			using (MagickImage image = new MagickImage(Files.Circle))
			{
				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:dlemstra,项目名称:GraphicsMagick.NET,代码行数:18,代码来源:MagickImageTests.cs

示例8: Test_Ping

		public void Test_Ping()
		{
			using (MagickImage image = new MagickImage())
			{
				image.Ping(Files.FujiFilmFinePixS1ProJPG);

				ExceptionAssert.Throws<MagickCacheErrorException>(delegate()
				{
					image.GetReadOnlyPixels();
				});

				ImageProfile profile = image.GetExifProfile();
				Assert.IsNotNull(profile);
			}
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:15,代码来源:MagickImageTests.cs

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