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


C# Cairo.ImageSurface类代码示例

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


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

示例1: CairoSurfaceWrapper

		public unsafe CairoSurfaceWrapper (Cairo.ImageSurface surface)
		{
			this.surface = surface;
			this.data_ptr = (ColorBgra*)surface.DataPtr;
			height = surface.Height;
			width = surface.Width;
		}
开发者ID:PintaProject,项目名称:Pinta.ImageManipulation,代码行数:7,代码来源:CairoSurfaceWrapper.cs

示例2: WithAlpha

        public static Gdk.Pixbuf WithAlpha (this Gdk.Pixbuf image, double opacity)
        {
            using (var surf = new Cairo.ImageSurface (Cairo.Format.Argb32, image.Width, image.Height)) {
                using (var g = new Cairo.Context (surf)) {
                    CairoHelper.SetSourcePixbuf (g, image, 0, 0);
                    g.PaintWithAlpha (opacity);
                }

                return new Gdk.Pixbuf (surf.Data, true, 8, surf.Width, surf.Height, surf.Stride);
            }
        }
开发者ID:msiyer,项目名称:Pinta,代码行数:11,代码来源:GdkExtensions.cs

示例3: StreamGeometryContextImpl

		public StreamGeometryContextImpl(Cairo.Path path = null)
        {

			_surf = new Cairo.ImageSurface (Cairo.Format.Argb32, 0, 0);
			_context = new Cairo.Context (_surf);
			this.Path = path;

			if (this.Path != null) 
			{
				_context.AppendPath(this.Path);
			}
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:12,代码来源:StreamGeometryContextImpl.cs

示例4: Create

 public override object Create(object img)
 {
     Gdk.Pixbuf pb = (Gdk.Pixbuf)img;
     var imgs = new Cairo.ImageSurface (Cairo.Format.ARGB32, pb.Width, pb.Height);
     var ic = new Cairo.Context (imgs);
     Gdk.CairoHelper.SetSourcePixbuf (ic, pb, 0, 0);
     ic.Paint ();
     imgs.Flush ();
     ((IDisposable)ic).Dispose ();
     var p = new Cairo.SurfacePattern (imgs);
     p.Extend = Cairo.Extend.Repeat;
     return p;
 }
开发者ID:garuma,项目名称:xwt,代码行数:13,代码来源:ImagePatternBackendHandler.cs

示例5: CreateContext

 public object CreateContext(Widget w)
 {
     GtkContext ctx = new GtkContext ();
     var b = (IGtkWidgetBackend)WidgetRegistry.GetBackend (w);
     if (!b.Widget.IsRealized) {
         Cairo.Surface sf = new Cairo.ImageSurface (Cairo.Format.ARGB32, 1, 1);
         Cairo.Context c = new Cairo.Context (sf);
         ctx.Context = c;
         ctx.TempSurface = sf;
     } else {
         ctx.Context = Gdk.CairoHelper.Create (b.Widget.GdkWindow);
     }
     return ctx;
 }
开发者ID:chkn,项目名称:xwt,代码行数:14,代码来源:ContextBackendHandler.cs

示例6: UpdateThumbnail

		private void UpdateThumbnail ()
		{
			double scalex = (double)Allocation.Width / (double)PintaCore.Workspace.ImageSize.Width;
			double scaley = (double)Allocation.Height / (double)PintaCore.Workspace.ImageSize.Height;
			
			thumbnail = new Cairo.ImageSurface (Cairo.Format.Argb32, Allocation.Width, Allocation.Height);
			
			using (Cairo.Context g = new Cairo.Context (thumbnail)) {
				g.Scale (scalex, scaley);
				foreach (Layer layer in PintaCore.Layers.GetLayersToPaint ()) {
					layer.Draw(g);
				}
			}
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:14,代码来源:PointPickerGraphic.cs

示例7: TestDrawLine

        public void TestDrawLine()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/line.png");
            image.Dispose ();
        }
开发者ID:bvssvni,项目名称:csharp-utils,代码行数:15,代码来源:TestDrawing.cs

示例8: Measure

		private void Measure ()
		{
			var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, 1, 1);
			
			using (Cairo.Context cr = new Cairo.Context(surface)) {			
				cr.SelectFontFace (FontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
				cr.SetFontSize (FontSize);
			
				var textExtents = cr.TextExtents (Text);

				Width = textExtents.Width;
				Height = Math.Abs (textExtents.YBearing);		
				Extent = textExtents.Height;
			}
		}
开发者ID:Octavio,项目名称:moro.PresentationFramework,代码行数:15,代码来源:FormattedText.cs

示例9: Render

		public void Render (List<Layer> layers, Cairo.ImageSurface dst, Gdk.Point offset)
		{
			dst.Flush ();

            // Our rectangle of interest
            var r = new Gdk.Rectangle (offset, dst.GetBounds ().Size).ToCairoRectangle ();

            using (var g = new Cairo.Context (dst)) {
                // Create the transparent checkerboard background
                g.Translate (-offset.X, -offset.Y);
                g.FillRectangle (r, tranparent_pattern, new Cairo.PointD (offset.X, offset.Y));

                for (var i = 0; i < layers.Count; i++) {
                    var layer = layers[i];

                    // If we're in LivePreview, substitute current layer with the preview layer
                    if (layer == PintaCore.Layers.CurrentLayer && PintaCore.LivePreview.IsEnabled)
                        layer = CreateLivePreviewLayer (layer);

                    // If the layer is offset, handle it here
                    if (!layer.Transform.IsIdentity ())
                        layer = CreateOffsetLayer (layer);

                    // No need to resize the surface if we're at 100% zoom
                    if (scale_factor.Ratio == 1)
                        layer.Draw (g, layer.Surface, layer.Opacity, false);
                    else {
                        using (var scaled = new Cairo.ImageSurface (Cairo.Format.Argb32, dst.Width, dst.Height)) {
                            g.Save ();
                            // Have to undo the translate set above
                            g.Translate (offset.X, offset.Y);
                            CopyScaled (layer.Surface, scaled, r.ToGdkRectangle ());
                            layer.Draw (g, scaled, layer.Opacity, false);
                            g.Restore ();
                        }
                    }
                }
            }

            // If we are at least 200% and grid is requested, draw it
            if (enable_pixel_grid && PintaCore.Actions.View.PixelGrid.Active && scale_factor.Ratio <= 0.5d)
                RenderPixelGrid (dst, offset);
			
			dst.MarkDirty ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:45,代码来源:CanvasRenderer.cs

示例10: TestDrawRectangle

        public void TestDrawRectangle()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new RectangleShape ();
            shape.Rectangle = new Rectangle () {
                X = 10.0,
                Y = 10.0,
                Width = 12.0,
                Height = 12.0
            };
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/rectangle.png");
            image.Dispose ();
        }
开发者ID:bvssvni,项目名称:csharp-utils,代码行数:21,代码来源:TestDrawing.cs

示例11: GetPattern

 public Cairo.Pattern GetPattern(ApplicationContext actx, double scaleFactor)
 {
     if (pattern == null || currentScaleFactor != scaleFactor) {
         if (pattern != null)
             pattern.Dispose ();
         Gdk.Pixbuf pb = ((GtkImage)Image.Backend).GetBestFrame (actx, scaleFactor, Image.Size.Width, Image.Size.Height, false);
         var imgs = new Cairo.ImageSurface (Cairo.Format.ARGB32, (int)(Image.Size.Width * scaleFactor), (int)(Image.Size.Height * scaleFactor));
         var ic = new Cairo.Context (imgs);
         ic.Scale ((double)imgs.Width / (double)pb.Width, (double)imgs.Height / (double)pb.Height);
         Gdk.CairoHelper.SetSourcePixbuf (ic, pb, 0, 0);
         ic.Paint ();
         imgs.Flush ();
         ((IDisposable)ic).Dispose ();
         pattern = new Cairo.SurfacePattern (imgs);
         pattern.Extend = Cairo.Extend.Repeat;
         var cm = new Cairo.Matrix ();
         cm.Scale (scaleFactor, scaleFactor);
         pattern.Matrix = cm;
         currentScaleFactor = scaleFactor;
     }
     return pattern;
 }
开发者ID:jbeaurain,项目名称:xwt,代码行数:22,代码来源:ImagePatternBackendHandler.cs

示例12: GtkTextLayoutBackendHandler

 static GtkTextLayoutBackendHandler()
 {
     using (Cairo.Surface sf = new Cairo.ImageSurface (Cairo.Format.ARGB32, 1, 1)) {
         SharedContext = new Cairo.Context (sf);
     }
 }
开发者ID:samclarke,项目名称:xwt,代码行数:6,代码来源:TextLayoutBackendHandler.cs

示例13: Reset

        public void Reset()
        {
            store.Clear ();

            if (active_layer_surface != null) {
                active_layer_surface.Dispose ();
                active_layer_surface = null;
            }

            if (!PintaCore.Workspace.HasOpenDocuments)
                return;

            var doc = PintaCore.Workspace.ActiveDocument;

            foreach (var layer in (doc.UserLayers as IEnumerable<Layer>).Reverse ()) {
                var surf = layer.Surface;

                // Draw the selection layer on top of the active layer.
                if (layer == doc.CurrentUserLayer && doc.ShowSelectionLayer) {
                    active_layer_surface = new Cairo.ImageSurface (Cairo.Format.Argb32, thumbnail_width,
                                                                   thumbnail_height);
                    canvas_renderer.Initialize (doc.ImageSize,
                                                new Gdk.Size (thumbnail_width, thumbnail_height));

                    var layers = new List<Layer> { layer, doc.SelectionLayer };
                    canvas_renderer.Render (layers, active_layer_surface, Gdk.Point.Zero);

                    surf = active_layer_surface;
                }

                store.AppendValues (surf, layer.Name, !layer.Hidden, layer);
            }

            SelectLayerInTreeView (PintaCore.Layers.Count - PintaCore.Layers.CurrentLayerIndex - 1);
        }
开发者ID:ericksson,项目名称:Pinta,代码行数:35,代码来源:LayersListWidget.cs

示例14: Start

		internal void Start (BaseEffect effect,
		                     Cairo.ImageSurface source,
		                     Cairo.ImageSurface dest,
		                     Gdk.Rectangle renderBounds)
		{
			Debug.WriteLine ("AsyncEffectRenderer.Start ()");
			
			if (effect == null)
				throw new ArgumentNullException ("effect");
			
			if (source == null)
				throw new ArgumentNullException ("source");
			
			if (dest == null)
				throw new ArgumentNullException ("dest");
			
			if (renderBounds.IsEmpty)
				throw new ArgumentException ("renderBounds.IsEmpty");
			
			// It is important the effect's properties don't change during rendering.
			// So a copy is made for the render.
			this.effect = effect.Clone();
			
			this.source_surface = source;
			this.dest_surface = dest;
			this.render_bounds = renderBounds;
			
			// If a render is already in progress, then cancel it,
			// and start a new render.
			if (IsRendering) {
				cancel_render_flag = true;
				restart_render_flag = true;
				return;
			}
			
			StartRender ();
		}
开发者ID:jobernolte,项目名称:Pinta,代码行数:37,代码来源:AsyncEffectRenderer.cs

示例15: ToSurface

        public static Cairo.Surface ToSurface (this Pixbuf pixbuf)
        {
            var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, pixbuf.Width, pixbuf.Height);

            using (var g = new Cairo.Context (surface)) {
                Gdk.CairoHelper.SetSourcePixbuf (g, pixbuf, 0, 0);
                g.Paint ();
            }

            return surface;
        }
开发者ID:msiyer,项目名称:Pinta,代码行数:11,代码来源:GdkExtensions.cs


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