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


C# ISurface.BeginUpdate方法代码示例

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


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

示例1: ApplyAndSwap

		private unsafe void ApplyAndSwap (ISurface dst, bool swap)
		{
			dst.BeginUpdate ();

			var dest_width = dst.Width;
			var dst_ptr = (ColorBgra*)dst.GetRowAddress (0);
			var mask_index = 0;
			ColorBgra swap_pixel;

			fixed (ColorBgra* fixed_ptr = pixels) {
				var pixel_ptr = fixed_ptr;
				dst_ptr += bounds.X + bounds.Y * dest_width;

				for (int y = bounds.Y; y <= bounds.Bottom; y++) {
					for (int x = bounds.X; x <= bounds.Right; x++) {
						if (bitmask[mask_index++])
							if (swap) {
								swap_pixel = *dst_ptr;
								*dst_ptr = *pixel_ptr;
								*pixel_ptr++ = swap_pixel;
							} else {
								*dst_ptr = *pixel_ptr++;
							}

						dst_ptr++;
					}

					dst_ptr += dest_width - bounds.Width;
				}
			}
			
			dst.EndUpdate ();
		}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:33,代码来源:SurfaceDiff.cs

示例2: ApplyLoop

		protected void ApplyLoop (ISurface src, ISurface dst, Rectangle roi, CancellationToken token, IRenderProgress progress)
		{
			src.BeginUpdate ();
			dst.BeginUpdate ();

			var completed_lines = new bool[roi.Height];
			var last_completed_index = 0;

			if (Settings.SingleThreaded || roi.Height <= 1) {
				for (var y = roi.Y; y <= roi.Bottom; ++y) {
					if (token.IsCancellationRequested)
						return;

					var dstPtr = dst.GetRowAddress (y);
					var srcPtr = src.GetRowAddress (y);
					Apply (srcPtr, dstPtr, roi.Width);

					completed_lines[y - roi.Top] = true;

					if (progress != null) {
						var last_y = FindLastCompletedLine (completed_lines, last_completed_index);
						last_completed_index = last_y;
						progress.CompletedRoi = new Rectangle (roi.X, roi.Y, roi.Width, last_y);
						progress.PercentComplete = (float)last_y / (float)roi.Height;
					}
				}
			} else {
				ParallelExtensions.OrderedFor (roi.Y, roi.Bottom + 1, token, (y) => {
					var dstPtr = dst.GetRowAddress (y);
					var srcPtr = src.GetRowAddress (y);
					Apply (srcPtr, dstPtr, roi.Width);

					completed_lines[y - roi.Top] = true;

					if (progress != null) {
						var last_y = FindLastCompletedLine (completed_lines, last_completed_index);
						last_completed_index = last_y;
						progress.CompletedRoi = new Rectangle (roi.X, roi.Y, roi.Width, last_y);
						progress.PercentComplete = (float)last_y / (float)roi.Height;
					}
				});
			}

			src.EndUpdate ();
			dst.EndUpdate ();
		}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:46,代码来源:BinaryPixelOp.cs

示例3: Render

		public unsafe void Render (ISurface surface, params Rectangle[] rois)
		{
			byte startAlpha;
			byte endAlpha;
			
			if (this.AlphaOnly) {
				ComputeAlphaOnlyValuesFromColors (this.startColor, this.endColor, out startAlpha, out endAlpha);
			} else {
				startAlpha = this.startColor.A;
				endAlpha = this.endColor.A;
			}
			
			surface.BeginUpdate ();
			
			for (int ri = 0; ri < rois.Length; ++ri) {
				var rect = rois[ri];
				
				if (this.StartPoint.X == this.EndPoint.X && this.StartPoint.Y == this.EndPoint.Y) {
					// Start and End point are the same ... fill with solid color.
					for (int y = rect.Top; y <= rect.Bottom; ++y) {
						var pixelPtr = surface.GetPointAddress(rect.Left, y);
						
						for (int x = rect.Left; x <= rect.Right; ++x) {
							ColorBgra result;
							
							if (this.AlphaOnly && this.AlphaBlending) {
								byte resultAlpha = (byte)Utility.FastDivideShortByByte ((ushort)(pixelPtr->A * endAlpha), 255);
								result = *pixelPtr;
								result.A = resultAlpha;
							} else if (this.AlphaOnly && !this.AlphaBlending) {
								result = *pixelPtr;
								result.A = endAlpha;
							} else if (!this.AlphaOnly && this.AlphaBlending) {
								result = this.normalBlendOp.Apply (*pixelPtr, this.endColor);
							//if (!this.alphaOnly && !this.alphaBlending)
							} else {
								result = this.endColor;
							}
							
							*pixelPtr = result;
							++pixelPtr;
						}
					}
				} else {
					var mainrect = rect;
					Parallel.ForEach(Enumerable.Range (rect.Top, rect.Bottom + 1),
						(y) => ProcessGradientLine(startAlpha, endAlpha, y, mainrect, surface));
				}
			}
			
			surface.EndUpdate ();
			AfterRender ();
		}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:53,代码来源:BaseGradientRenderer.cs

示例4: RenderLoop

		protected unsafe virtual void RenderLoop (ISurface surface, Rectangle roi, CancellationToken token, IRenderProgress progress)
		{
			var dst = new ColorBgra[surface.Height * surface.Width];

			fixed (ColorBgra* dst_ptr = dst) {
				var dst_wrap = new ColorBgraArrayWrapper (dst_ptr, surface.Width, surface.Height);

				surface.BeginUpdate ();
				dst_wrap.BeginUpdate ();

				OnBeginRender (surface, dst_wrap, roi);

				var completed_lines = new bool[roi.Height];
				var last_completed_index = 0;

				if (Settings.SingleThreaded || roi.Height <= 1) {
					for (var y = roi.Y; y <= roi.Bottom; ++y) {
						if (token.IsCancellationRequested)
							return;

						RenderLine (surface, dst_wrap, new Rectangle (roi.X, y, roi.Width, 1));

						completed_lines[y - roi.Top] = true;

						if (progress != null) {
							var last_y = FindLastCompletedLine (completed_lines, last_completed_index);
							last_completed_index = last_y;
							progress.CompletedRoi = new Rectangle (roi.X, roi.Y, roi.Width, last_y);
							progress.PercentComplete = (float)last_y / (float)roi.Height;
						}
					}
				} else {
					ParallelExtensions.OrderedFor (roi.Y, roi.Bottom + 1, token, (y) => {
						RenderLine (surface, dst_wrap, new Rectangle (roi.X, y, roi.Width, 1));

						completed_lines[y - roi.Top] = true;

						if (progress != null) {
							var last_y = FindLastCompletedLine (completed_lines, last_completed_index);
							last_completed_index = last_y;
							progress.CompletedRoi = new Rectangle (roi.X, roi.Y, roi.Width, last_y);
							progress.PercentComplete = (float)last_y / (float)roi.Height;
						}
					});
				}

				// Copy the result from our temp destination back into the source
				var op = new IdentityOp ();
				op.ApplyAsync (dst_wrap, surface, token).Wait ();

				surface.EndUpdate ();
				dst_wrap.EndUpdate ();
			}
		}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:54,代码来源:BaseEffect.cs


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