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


C# Cairo.GetPointAddress方法代码示例

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


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

示例1: Apply

		/// <summary>
		/// Provides a default implementation for performing dst = F(lhs, rhs) over some rectangle of interest.
		/// </summary>
		/// <param name="dst">The Surface to write pixels to.</param>
		/// <param name="dstOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the dst Surface.</param>
		/// <param name="lhs">The Surface to read pixels from for the lhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b>.</param>
		/// <param name="lhsOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the lhs Surface.</param>
		/// <param name="rhs">The Surface to read pixels from for the rhs parameter given to the method <b>ColorBgra Apply(ColorBgra, ColorBgra)</b></param>
		/// <param name="rhsOffset">The pixel offset that defines the upper-left of the rectangle-of-interest for the rhs Surface.</param>
		/// <param name="roiSize">The size of the rectangles-of-interest for all Surfaces.</param>
		public void Apply (Cairo.ImageSurface dst, Point dstOffset,
				  Cairo.ImageSurface lhs, Point lhsOffset,
				  Cairo.ImageSurface rhs, Point rhsOffset,
				  Size roiSize)
		{
			// Bounds checking only enabled in Debug builds.
#if DEBUG
			// Create bounding rectangles for each Surface
			Rectangle dstRect = new Rectangle (dstOffset, roiSize);
			Rectangle lhsRect = new Rectangle (lhsOffset, roiSize);
			Rectangle rhsRect = new Rectangle (rhsOffset, roiSize);

			// Clip those rectangles to those Surface's bounding rectangles
			Rectangle dstClip = Rectangle.Intersect (dstRect, dst.GetBounds ());
			Rectangle lhsClip = Rectangle.Intersect (lhsRect, lhs.GetBounds ());
			Rectangle rhsClip = Rectangle.Intersect (rhsRect, rhs.GetBounds ());

			// If any of those Rectangles actually got clipped, then throw an exception
			if (dstRect != dstClip) {
				throw new ArgumentOutOfRangeException ("roiSize", "Destination roi out of bounds");
			}

			if (lhsRect != lhsClip) {
				throw new ArgumentOutOfRangeException ("roiSize", "lhs roi out of bounds");
			}

			if (rhsRect != rhsClip) {
				throw new ArgumentOutOfRangeException ("roiSize", "rhs roi out of bounds");
			}
#endif

			// Cache the width and height properties
			int width = roiSize.Width;
			int height = roiSize.Height;

			// Do the work.
			unsafe {
				for (int row = 0; row < height; ++row) {
					ColorBgra* dstPtr = dst.GetPointAddress (dstOffset.X, dstOffset.Y + row);
					ColorBgra* lhsPtr = lhs.GetPointAddress (lhsOffset.X, lhsOffset.Y + row);
					ColorBgra* rhsPtr = rhs.GetPointAddress (rhsOffset.X, rhsOffset.Y + row);

					Apply (dstPtr, lhsPtr, rhsPtr, width);
				}
			}
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:56,代码来源:BinaryPixelOp.cs

示例2: RenderPixelGrid

        private unsafe void RenderPixelGrid(Cairo.ImageSurface dst, Gdk.Point offset)
        {
            // Draw horizontal lines
            var dst_ptr = (ColorBgra*)dst.DataPtr;
            int dstHeight = dst.Height;
            int dstWidth = dst.Width;
            int dstStride = dst.Stride;
            int sTop = d2sLookupY[offset.Y];
            int sBottom = d2sLookupY[offset.Y + dstHeight];

            for (int srcY = sTop; srcY <= sBottom; ++srcY) {
                int dstY = s2dLookupY[srcY];
                int dstRow = dstY - offset.Y;

                if (dstRow >= 0 && dstRow < dstHeight) {
                    ColorBgra* dstRowPtr = dst.GetRowAddressUnchecked (dst_ptr, dstWidth, dstRow);
                    ColorBgra* dstRowEndPtr = dstRowPtr + dstWidth;

                    dstRowPtr += offset.X & 1;

                    while (dstRowPtr < dstRowEndPtr) {
                        *dstRowPtr = ColorBgra.Black;
                        dstRowPtr += 2;
                    }
                }
            }

            // Draw vertical lines
            int sLeft = d2sLookupX[offset.X];
            int sRight = d2sLookupX[offset.X + dstWidth];

            for (int srcX = sLeft; srcX <= sRight; ++srcX) {
                int dstX = s2dLookupX[srcX];
                int dstCol = dstX - offset.X;

                if (dstCol >= 0 && dstCol < dstWidth) {
                    byte* dstColPtr = (byte*)dst.GetPointAddress (dstCol, 0);
                    byte* dstColEndPtr = dstColPtr + dstStride * dstHeight;

                    dstColPtr += (offset.Y & 1) * dstStride;

                    while (dstColPtr < dstColEndPtr) {
                        *((ColorBgra*)dstColPtr) = ColorBgra.Black;
                        dstColPtr += 2 * dstStride;
                    }
                }
            }
        }
开发者ID:Kharevich,项目名称:Pinta,代码行数:48,代码来源:CanvasRenderer.cs

示例3: Render

        public unsafe void Render(Cairo.ImageSurface dst, Gdk.Point offset)
        {
            if (cr.ScaleFactor > new ScaleFactor(1, 2))
            {
                return;
            }

            int[] d2SLookupX = cr.Dst2SrcLookupX;
            int[] d2SLookupY = cr.Dst2SrcLookupY;
            int[] s2DLookupX = cr.Src2DstLookupX;
            int[] s2DLookupY = cr.Src2DstLookupY;

            ColorBgra[] blackAndWhite = new ColorBgra[2] { ColorBgra.White, ColorBgra.Black };

            // draw horizontal lines
            int sTop = d2SLookupY[offset.Y];
            int sBottom = d2SLookupY[offset.Y + dst.Height];
            int dstHeight = dst.Height;
            int dstWidth = dst.Width;

            for (int srcY = sTop; srcY <= sBottom; ++srcY)
            {
                int dstY = s2DLookupY[srcY];
                int dstRow = dstY - offset.Y;

                if (dstRow < dstHeight)
                {
                    ColorBgra *dstRowPtr = dst.GetRowAddressUnchecked(dstRow);
                    ColorBgra *dstRowEndPtr = dstRowPtr + dst.Width;

                    dstRowPtr += offset.X & 1;

                    while (dstRowPtr < dstRowEndPtr)
                    {
                        *dstRowPtr = ColorBgra.Black;
                        dstRowPtr += 2;
                    }
                }
            }

            // draw vertical lines
            int sLeft = d2SLookupX[offset.X];
            int sRight = d2SLookupX[offset.X + dst.Width];

            for (int srcX = sLeft; srcX <= sRight; ++srcX)
            {
                int dstX = s2DLookupX[srcX];
                int dstCol = dstX - offset.X;

                if (dstCol < dstWidth)
                {
                    byte *dstColPtr = (byte *)dst.GetPointAddress(dstCol, 0);
                    byte *dstColEndPtr = dstColPtr + dst.Stride * dst.Height;

                    dstColPtr += (offset.Y & 1) * dst.Stride;

                    while (dstColPtr < dstColEndPtr)
                    {
                        *((ColorBgra *)dstColPtr) = ColorBgra.Black;
                        dstColPtr += 2 * dst.Stride;
                    }
                }
            }
        }
开发者ID:mrolappe,项目名称:Pinta,代码行数:64,代码来源:GridRenderer.cs


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