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


C# ImageBuffer.GetBytesBetweenPixelsInclusive方法代码示例

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


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

示例1: pixel_high_res

		public void pixel_high_res(ImageBuffer sourceImage, RGBA_Bytes[] destBuffer, int destBufferOffset, int x, int y)
		{
			int r, g, b, a;
			r = g = b = a = LineAABasics.line_subpixel_scale * LineAABasics.line_subpixel_scale / 2;

			int weight;
			int x_lr = x >> LineAABasics.line_subpixel_shift;
			int y_lr = y >> LineAABasics.line_subpixel_shift;

			x &= LineAABasics.line_subpixel_mask;
			y &= LineAABasics.line_subpixel_mask;
			int sourceOffset;
			byte[] ptr = sourceImage.GetPixelPointerXY(x_lr, y_lr, out sourceOffset);

			weight = (LineAABasics.line_subpixel_scale - x) *
					 (LineAABasics.line_subpixel_scale - y);
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			sourceOffset += sourceImage.GetBytesBetweenPixelsInclusive();

			weight = x * (LineAABasics.line_subpixel_scale - y);
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			ptr = sourceImage.GetPixelPointerXY(x_lr, y_lr + 1, out sourceOffset);

			weight = (LineAABasics.line_subpixel_scale - x) * y;
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			sourceOffset += sourceImage.GetBytesBetweenPixelsInclusive();

			weight = x * y;
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			destBuffer[destBufferOffset].red = (byte)(r >> LineAABasics.line_subpixel_shift * 2);
			destBuffer[destBufferOffset].green = (byte)(g >> LineAABasics.line_subpixel_shift * 2);
			destBuffer[destBufferOffset].blue = (byte)(b >> LineAABasics.line_subpixel_shift * 2);
			destBuffer[destBufferOffset].alpha = (byte)(a >> LineAABasics.line_subpixel_shift * 2);
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:50,代码来源:agg_pattern_filters_rgba.cs

示例2: FindLeastSquaresMatch

		public bool FindLeastSquaresMatch(ImageBuffer imageToFind, out Vector2 bestPosition, out double bestLeastSquares, double maxError = double.MaxValue)
		{
			bestPosition = Vector2.Zero;
			bestLeastSquares = double.MaxValue;

			if (Width >= imageToFind.Width
				&& Height >= imageToFind.Height
				&& BitDepth == imageToFind.BitDepth)
			{
				int bytesPerPixel = BitDepth / 8;
				int aDistanceBetweenPixels = GetBytesBetweenPixelsInclusive();
				int bDistanceBetweenPixels = imageToFind.GetBytesBetweenPixelsInclusive();
				byte[] thisBuffer = GetBuffer();
				byte[] containedBuffer = imageToFind.GetBuffer();
				for (int matchY = 0; matchY <= Height - imageToFind.Height; matchY++)
				{
					for (int matchX = 0; matchX <= Width - imageToFind.Width; matchX++)
					{
						double currentLeastSquares = 0;

						for (int imageToFindY = 0; imageToFindY < imageToFind.Height; imageToFindY++)
						{
							int thisBufferOffset = GetBufferOffsetXY(matchX, matchY + imageToFindY);
							int imageToFindBufferOffset = imageToFind.GetBufferOffsetY(imageToFindY);
							for (int imageToFindX = 0; imageToFindX < imageToFind.Width; imageToFindX++)
							{
								for (int byteIndex = 0; byteIndex < bytesPerPixel; byteIndex++)
								{
									byte aByte = thisBuffer[thisBufferOffset + byteIndex];
									byte bByte = containedBuffer[imageToFindBufferOffset + byteIndex];
									int difference = (int)aByte - (int)bByte;
									currentLeastSquares += difference * difference;
								}
								thisBufferOffset += aDistanceBetweenPixels;
								imageToFindBufferOffset += bDistanceBetweenPixels;
								if (currentLeastSquares > maxError)
								{
									// stop checking we have too much error.
									imageToFindX = imageToFind.Width;
									imageToFindY = imageToFind.Height;
								}
							}
						}

						if (currentLeastSquares < bestLeastSquares)
						{
							bestPosition = new Vector2(matchX, matchY);
							bestLeastSquares = currentLeastSquares;
							if (maxError > currentLeastSquares)
							{
								maxError = currentLeastSquares;
								if (currentLeastSquares == 0)
								{
									return true;
								}
							}
						}
					}
				}
			}

			return bestLeastSquares <= maxError;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:63,代码来源:ImageBuffer.cs

示例3: Equals

		public bool Equals(ImageBuffer b, int maxError = 0)
		{
			if (Width == b.Width
				&& Height == b.Height
				&& BitDepth == b.BitDepth
				&& StrideInBytes() == b.StrideInBytes()
				&& m_OriginOffset == b.m_OriginOffset)
			{
				int bytesPerPixel = BitDepth / 8;
				int aDistanceBetweenPixels = GetBytesBetweenPixelsInclusive();
				int bDistanceBetweenPixels = b.GetBytesBetweenPixelsInclusive();
				byte[] aBuffer = GetBuffer();
				byte[] bBuffer = b.GetBuffer();
				for (int y = 0; y < Height; y++)
				{
					int aBufferOffset = GetBufferOffsetY(y);
					int bBufferOffset = b.GetBufferOffsetY(y);
					for (int x = 0; x < Width; x++)
					{
						for (int byteIndex = 0; byteIndex < bytesPerPixel; byteIndex++)
						{
							byte aByte = aBuffer[aBufferOffset + byteIndex];
							byte bByte = bBuffer[bBufferOffset + byteIndex];
							if (aByte < (bByte - maxError) || aByte > (bByte + maxError))
							{
								return false;
							}
						}
						aBufferOffset += aDistanceBetweenPixels;
						bBufferOffset += bDistanceBetweenPixels;
					}
				}
				return true;
			}

			return false;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:37,代码来源:ImageBuffer.cs

示例4: Contains

		public bool Contains(ImageBuffer imageToFind, out int matchX, out int matchY, int maxError = 0)
		{
			matchX = 0;
			matchY = 0;
			if (Width >= imageToFind.Width
				&& Height >= imageToFind.Height
				&& BitDepth == imageToFind.BitDepth)
			{
				int bytesPerPixel = BitDepth / 8;
				int aDistanceBetweenPixels = GetBytesBetweenPixelsInclusive();
				int bDistanceBetweenPixels = imageToFind.GetBytesBetweenPixelsInclusive();
				byte[] thisBuffer = GetBuffer();
				byte[] containedBuffer = imageToFind.GetBuffer();
				for (matchY = 0; matchY <= Height - imageToFind.Height; matchY++)
				{
					for (matchX = 0; matchX <= Width - imageToFind.Width; matchX++)
					{
						bool foundBadMatch = false;
						for (int imageToFindY = 0; imageToFindY < imageToFind.Height; imageToFindY++)
						{
							int thisBufferOffset = GetBufferOffsetXY(matchX, matchY + imageToFindY);
							int imageToFindBufferOffset = imageToFind.GetBufferOffsetY(imageToFindY);
							for (int imageToFindX = 0; imageToFindX < imageToFind.Width; imageToFindX++)
							{
								for (int byteIndex = 0; byteIndex < bytesPerPixel; byteIndex++)
								{
									byte aByte = thisBuffer[thisBufferOffset + byteIndex];
									byte bByte = containedBuffer[imageToFindBufferOffset + byteIndex];
									if (aByte < (bByte - maxError) || aByte > (bByte + maxError))
									{
										foundBadMatch = true;
										byteIndex = bytesPerPixel;
										imageToFindX = imageToFind.Width;
										imageToFindY = imageToFind.Height;
									}
								}
								thisBufferOffset += aDistanceBetweenPixels;
								imageToFindBufferOffset += bDistanceBetweenPixels;
							}
						}
						if (!foundBadMatch)
						{
							return true;
						}
					}
				}
			}

			return false;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:50,代码来源:ImageBuffer.cs

示例5: ImageBuffer

		public ImageBuffer(ImageBuffer sourceImage)
		{
			SetDimmensionAndFormat(sourceImage.Width, sourceImage.Height, sourceImage.StrideInBytes(), sourceImage.BitDepth, sourceImage.GetBytesBetweenPixelsInclusive(), true);
			int offset = sourceImage.GetBufferOffsetXY(0, 0);
			byte[] buffer = sourceImage.GetBuffer();
			byte[] newBuffer = new byte[buffer.Length];
			agg_basics.memcpy(newBuffer, offset, buffer, offset, buffer.Length - offset);
			SetBuffer(newBuffer, offset);
			SetRecieveBlender(sourceImage.GetRecieveBlender());
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:10,代码来源:ImageBuffer.cs


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