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


C# Cairo.SetSourceSurface方法代码示例

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


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

示例1: Paint

        public override void Paint(Cairo.Context gr, Rectangle rect, string subPart = "")
        {
            float widthRatio = 1f;
            float heightRatio = 1f;

            if (Scaled){
                widthRatio = (float)rect.Width / Dimensions.Width;
                heightRatio = (float)rect.Height / Dimensions.Height;
            }

            if (KeepProportions) {
                if (widthRatio < heightRatio)
                    heightRatio = widthRatio;
                else
                    widthRatio = heightRatio;
            }

            gr.Save ();

            gr.Translate (rect.Left,rect.Top);
            gr.Scale (widthRatio, heightRatio);
            gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2);

            using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32,
                Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width)) {
                gr.SetSourceSurface (imgSurf, 0,0);
                gr.Paint ();
            }
            gr.Restore ();
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:30,代码来源:BmpPicture.cs

示例2: OnRender

		protected override void OnRender (Cairo.Context context)
		{
			if (surfaceCache == null) {
				// will improve with CGLayer surfaces
				surfaceCache = new SurfaceWrapper (context, pbuf);
			}
			int x = (int)((Width - pbuf.Width) * XAlign);
			int y = (int)((Height - pbuf.Height) * YAlign);
			context.SetSourceSurface (surfaceCache.Surface, x, y);
			double opacity = Opacity;
			if (opacity == 1)
				context.Paint ();
			else
				context.PaintWithAlpha (Opacity);

			base.OnRender (context);
		}
开发者ID:jassmith,项目名称:Xamarin.Canvas,代码行数:17,代码来源:ImageCanvasElement.cs

示例3: RenderLivePreviewLayer

		// Used by the workspace drawing area expose render loop.
		// Takes care of the clipping.
		public void RenderLivePreviewLayer (Cairo.Context ctx, double opacity)
		{
			if (!IsEnabled)
				throw new InvalidOperationException ("Tried to render a live preview after live preview has ended.");
						
			// TODO remove seam around selection during live preview.
			
			ctx.Save ();
			if (selection_path != null) {
				
				// Paint area outsize of the selection path, with the pre-effect image.
				var imageSize = PintaCore.Workspace.ImageSize;
				ctx.Rectangle (0, 0, imageSize.Width, imageSize.Height);
				ctx.AppendPath (selection_path);
				ctx.Clip ();
				ctx.SetSourceSurface (layer.Surface, (int)layer.Offset.X, (int)layer.Offset.Y);
				ctx.PaintWithAlpha (opacity);
				ctx.ResetClip ();
				
				// Paint area inside the selection path, with the post-effect image.
				ctx.AppendPath (selection_path);
				ctx.Clip ();
				
				ctx.SetSourceSurface (live_preview_surface, (int)layer.Offset.X, (int)layer.Offset.Y);
				ctx.PaintWithAlpha (opacity);
				
				ctx.AppendPath (selection_path);
				ctx.FillRule = Cairo.FillRule.EvenOdd;
				ctx.Clip ();			
			} else {
				
				ctx.SetSourceSurface (live_preview_surface, (int)layer.Offset.X, (int)layer.Offset.Y);
				ctx.PaintWithAlpha (opacity);				
			}
			ctx.Restore ();
		}
开发者ID:cameronwhite,项目名称:Pinta,代码行数:38,代码来源:LivePreviewManager.cs

示例4: RenderIcon

		void RenderIcon (Cairo.Context context, SurfaceWrapper surface, double opacity)
		{
			context.SetSourceSurface (surface.Surface, 
			                          Allocation.X + (Allocation.Width - surface.Width) / 2,
			                          Allocation.Y + (Allocation.Height - surface.Height) / 2);

			context.PaintWithAlpha (opacity);
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:8,代码来源:DockBarItem.cs

示例5: Render

 public void Render(Cairo.Context context, int x, int y, int width, int height)
 {
     // scale and draw moodbar
     double scaled_width = (width) / 1000.0;
     context.Save ();
     context.Scale (scaled_width, height * 2);
     context.SetSourceSurface (Surface, (int)(x / scaled_width), y);
     context.Paint ();
     context.Restore ();
 }
开发者ID:X4lldux,项目名称:banshee-moodbar-extension,代码行数:10,代码来源:Moodbar.cs

示例6: RenderPreview

		void RenderPreview (Cairo.Context context, Gdk.Point position, double opacity)
		{
			if (brandedIcon != null) {
				if (previewSurface == null) {
					previewSurface = new SurfaceWrapper (context, brandedIcon);
				}
				double scale = PreviewSize / previewSurface.Width;

				context.Save ();
				context.Translate (position.X, position.Y);
				context.Scale (scale * IconScale, scale * IconScale);
				context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2);
				context.PaintWithAlpha (opacity);
				context.Restore ();
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:16,代码来源:WelcomePageFirstRun.cs

示例7: CachedDraw

		/// TODO: CairoExtensions.CachedDraw seems not to work correctly for me.
		public static void CachedDraw (Cairo.Context self, ref SurfaceWrapper surface, Gdk.Rectangle region, object parameters = null, float opacity = 1.0f, Action<Cairo.Context, float> draw = null, double? forceScale = null)
		{
			double displayScale = forceScale.HasValue ? forceScale.Value : QuartzSurface.GetRetinaScale (self);
			int targetWidth = (int) (region.Width * displayScale);
			int targetHeight = (int) (region.Height * displayScale);

			bool redraw = false;
			if (surface == null || surface.Width != targetWidth || surface.Height != targetHeight) {
				if (surface != null)
					surface.Dispose ();
				surface = new SurfaceWrapper (self, targetWidth, targetHeight);
				redraw = true;
			} else if ((surface.Data == null && parameters != null) || (surface.Data != null && !surface.Data.Equals (parameters))) {
				redraw = true;
			}


			if (redraw) {
				surface.Data = parameters;
				using (var context = new Cairo.Context (surface.Surface)) {
					draw(context, 1.0f);
				}
			}

			self.SetSourceSurface (surface.Surface, 0, 0);
			self.Paint ();
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:28,代码来源:QuickTaskOverviewMode.cs

示例8: OnDrawn

		protected override bool OnDrawn (Cairo.Context ctx)
		{
			ctx.SetSourceSurface (surface, 0, 0);
			ctx.Paint ();
			return false;
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:6,代码来源:Scribble.cs


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