• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Cairo.Surface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ImageInfo

        public ImageInfo(ImageInfo info, Gdk.Rectangle allocation)
        {
            #if false
            Surface = new ImageSurface (Format.RGB24,
                            allocation.Width,
                            allocation.Height);
            Context ctx = new Context (Surface);
            #else
            Console.WriteLine ("source status = {0}", info.Surface.Status);
            Surface = info.Surface.CreateSimilar (Content.Color,
                                  allocation.Width,
                                  allocation.Height);

            System.Console.WriteLine ("status = {1} pointer = {0}", Surface.Handle.ToString (), Surface.Status);
            Context ctx = new Context (Surface);
            #endif
            Bounds = allocation;

            ctx.Matrix = info.Fill (allocation);
            Pattern p = new SurfacePattern (info.Surface);
            ctx.Source = p;
            ctx.Paint ();
            ((IDisposable)ctx).Dispose ();
            p.Destroy ();
        }
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:25,代码来源:ImageInfo.cs


示例2: SurfaceToPngBytes

		public static byte[] SurfaceToPngBytes(Surface surface)
		{
			using (var ms = new MemoryStream())
			{
				SurfaceToPngStream(surface, ms);
				return ms.ToArray();
			}
		}
开发者ID:pruiz,项目名称:Mono.CairoWarp,代码行数:8,代码来源:CairoStreamWriter.cs


示例3: SurfaceToPngStream

		public static void SurfaceToPngStream(Surface surface, BinaryWriter writer)
		{
			var obj = new CairoStreamWriter(writer);
			var fn = new cairo_write_func_t(obj.do_write);
			var status = cairo_surface_write_to_png_stream(surface.Handle, fn, IntPtr.Zero);

			if (status != Status.Success)
				throw new InvalidOperationException("Status: " + status);
		}
开发者ID:pruiz,项目名称:Mono.CairoWarp,代码行数:9,代码来源:CairoStreamWriter.cs


示例4: CellRendererSurface

        public CellRendererSurface(int width, int height)
        {
            // TODO: Respect cell padding (Xpad and Ypad).
            SetFixedSize (width, height);

            transparent = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
            Cairo.Color gray = new Cairo.Color (.75, .75, .75);

            // Create checkerboard background
            int grid_width = 4;

            using (Cairo.Context g = new Cairo.Context (transparent)) {
                g.Color = new Cairo.Color (1, 1, 1);
                g.Paint ();

                for (int y = 0; y < height; y += grid_width)
                    for (int x = 0; x < width; x += grid_width)
                        if ((x / grid_width % 2) + (y / grid_width % 2) == 1)
                            g.FillRectangle (new Cairo.Rectangle (x, y, grid_width, grid_width), gray);
            }
        }
开发者ID:xxgreg,项目名称:Pinta,代码行数:21,代码来源:CellRendererSurface.cs


示例5: ClearDrawing

 public void ClearDrawing()
 {
     drawings.Destroy();
     drawings = new ImageSurface(Format.ARGB32,sourceWidth,sourceHeight);
     QueueDraw();
 }
开发者ID:dineshkummarc,项目名称:longomatch,代码行数:6,代码来源:DrawingWidget.cs


示例6: CreatePixbuf

 private static Gdk.Pixbuf CreatePixbuf(Surface s)
 {
     IntPtr result = f_pixbuf_from_cairo_surface (s.Handle);
     return (Gdk.Pixbuf) GLib.Object.GetObject (result, true);
 }
开发者ID:GNOME,项目名称:f-spot,代码行数:5,代码来源:PrintOperation.cs


示例7: Graphics

 public Graphics(Surface surface)
     : base(surface)
 {
 }
开发者ID:knocte,项目名称:gtk-sharp,代码行数:4,代码来源:Context.cs


示例8: SetTarget

 public void SetTarget(Surface target)
 {
     if (handle != IntPtr.Zero)
         NativeMethods.cairo_destroy (handle);
     handle = NativeMethods.cairo_create (target.Handle);
 }
开发者ID:knocte,项目名称:gtk-sharp,代码行数:6,代码来源:Context.cs


示例9: SetSource

 public void SetSource(Surface source)
 {
     NativeMethods.cairo_set_source_surface (handle, source.Handle, 0, 0);
 }
开发者ID:knocte,项目名称:gtk-sharp,代码行数:4,代码来源:Context.cs


示例10: MaskSurface

 public void MaskSurface(Surface surface, double surface_x, double surface_y)
 {
     NativeMethods.cairo_mask_surface (handle, surface.Handle, surface_x, surface_y);
 }
开发者ID:knocte,项目名称:gtk-sharp,代码行数:4,代码来源:Context.cs


示例11: Invert

        /// <summary>
        /// Inverts the selection.
        /// </summary>
        /// <param name="surface">
        /// Surface for the selection path.
        /// </param>
        /// <param name='imageSize'>
        /// The size of the document.
        /// </param>
        public void Invert(Surface surface, Gdk.Size imageSize)
        {
            List<List<IntPoint>> resultingPolygons = new List<List<IntPoint>> ();

            var documentPolygon = CreateRectanglePolygon (new Rectangle (0, 0, imageSize.Width, imageSize.Height));

            // Create a rectangle that is the size of the entire image,
            // and subtract all of the polygons in the current selection from it.
            SelectionClipper.AddPolygon (documentPolygon, PolyType.ptSubject);
            SelectionClipper.AddPolygons (SelectionPolygons, PolyType.ptClip);
            SelectionClipper.Execute (ClipType.ctDifference, resultingPolygons);

            SelectionClipper.Clear ();

            SelectionPolygons = resultingPolygons;
            using (Context g = new Context (surface)) {
                SelectionPath = g.CreatePolygonPath (ConvertToPolygonSet (resultingPolygons));
            }
        }
开发者ID:bodicsek,项目名称:Pinta,代码行数:28,代码来源:DocumentSelection.cs


示例12: CreateEllipseSelection

        /// <summary>
        /// Create an elliptical Selection from a bounding Rectangle.
        /// </summary>
        /// <param name="selectionSurface">The selection surface to use for calculating the elliptical Path.</param>
        /// <param name="r">The bounding Rectangle surrounding the ellipse.</param>
        public void CreateEllipseSelection(Surface selectionSurface, Rectangle r)
        {
            using (Context g = new Context(selectionSurface))
            {
                SelectionPath = g.CreateEllipsePath(r);
            }

            //These values were calculated in the static CreateEllipsePath method
            //in Pinta.Core.CairoExtensions, so they were used here as well.
            double rx = r.Width / 2; //1/2 of the bounding Rectangle Width.
            double ry = r.Height / 2; //1/2 of the bounding Rectangle Height.
            double cx = r.X + rx; //The middle of the bounding Rectangle, horizontally speaking.
            double cy = r.Y + ry; //The middle of the bounding Rectangle, vertically speaking.
            double c1 = 0.552285; //A constant factor used to give the least approximation error.

            //Clear the Selection Polygons collection to start from a clean slate.
            SelectionPolygons.Clear();

            //Calculate an appropriate interval at which to increment t based on
            //the bounding Rectangle's Width and Height properties. The increment
            //for t determines how many intermediate Points to calculate for the
            //ellipse. For each curve, t will go from tInterval to 1. The lower
            //the value of tInterval, the higher number of intermediate Points
            //that will be calculated and stored into the Polygon collection.
            double tInterval = 1d / (r.Width + r.Height);

            //Create a new Polygon to store the upcoming ellipse.
            List<IntPoint> newPolygon = new List<IntPoint>();

            //These values were also calculated in the CreateEllipsePath method. This is where
            //the ellipse's 4 curves (and all of the Points on each curve) are determined.
            //Note: each curve is consecutive to the previous one, but they *do not* overlap,
            //other than the first/last Point (which is how it is supposed to work).

            //The starting Point.
            newPolygon.Add(new IntPoint((long)(cx + rx), (long)cy));

            //Curve 1.
            newPolygon.AddRange(CalculateCurvePoints(tInterval,
                cx + rx, cy,
                cx + rx, cy - c1 * ry,
                cx + c1 * rx, cy - ry,
                cx, cy - ry));

            //Curve 2.
            newPolygon.AddRange(CalculateCurvePoints(tInterval,
                cx, cy - ry,
                cx - c1 * rx, cy - ry,
                cx - rx, cy - c1 * ry,
                cx - rx, cy));

            //Curve 3.
            newPolygon.AddRange(CalculateCurvePoints(tInterval,
                cx - rx, cy,
                cx - rx, cy + c1 * ry,
                cx - c1 * rx, cy + ry,
                cx, cy + ry));

            //Curve 4.
            newPolygon.AddRange(CalculateCurvePoints(tInterval,
                cx, cy + ry,
                cx + c1 * rx, cy + ry,
                cx + rx, cy + c1 * ry,
                cx + rx, cy));

            //Add the newly calculated elliptical Polygon.
            SelectionPolygons.Add(newPolygon);
        }
开发者ID:bodicsek,项目名称:Pinta,代码行数:73,代码来源:DocumentSelection.cs


示例13: SetPixbuf

 private void SetPixbuf(Pixbuf pixbuf)
 {
     Surface = CairoUtils.CreateSurface (pixbuf);
     Bounds.Width = pixbuf.Width;
     Bounds.Height = pixbuf.Height;
 }
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:6,代码来源:ImageInfo.cs


示例14: Pattern

 public Pattern(Surface surface)
 {
     pattern = NativeMethods.cairo_pattern_create_for_surface (surface.Handle);
 }
开发者ID:nuxleus,项目名称:gtk-sharp,代码行数:4,代码来源:Pattern.cs


示例15: ImageInfo

        public ImageInfo(ImageInfo info, Gdk.Rectangle allocation)
        {
            Surface = info.Surface.CreateSimilar (Content.Color,
                                  allocation.Width,
                                  allocation.Height);

            var ctx = new Context (Surface);
            Bounds = allocation;

            ctx.Matrix = info.Fill (allocation);
            Pattern p = new SurfacePattern (info.Surface);
            ctx.SetSource (p);
            ctx.Paint ();
            ctx.Dispose ();
            p.Dispose ();
        }
开发者ID:modulexcite,项目名称:f-spot,代码行数:16,代码来源:ImageInfo.cs


示例16: SetPixbuf

 void SetPixbuf(Pixbuf pixbuf)
 {
     Surface = Hyena.Gui.PixbufImageSurface.Create(pixbuf);
     Bounds.Width = pixbuf.Width;
     Bounds.Height = pixbuf.Height;
 }
开发者ID:modulexcite,项目名称:f-spot,代码行数:6,代码来源:ImageInfo.cs


示例17: CreateRectangleSelection

        /// <summary>
        /// Create a rectangular Selection from a Rectangle.
        /// </summary>
        /// <param name="selectionSurface">The selection surface to use for calculating the rectangular Path.</param>
        /// <param name="r">The Rectangle.</param>
        public void CreateRectangleSelection(Surface selectionSurface, Rectangle r)
        {
            using (Context g = new Context(selectionSurface))
            {
                SelectionPath = g.CreateRectanglePath(r);
            }

            //Clear the Selection Polygons collection to start from a clean slate.
            SelectionPolygons.Clear();

            SelectionPolygons.Add (CreateRectanglePolygon (r));
        }
开发者ID:bodicsek,项目名称:Pinta,代码行数:17,代码来源:DocumentSelection.cs


示例18: Context

 public Context(Surface surface)
 {
     state = NativeMethods.cairo_create (surface.Handle);
 }
开发者ID:eswarpr,项目名称:gtk-sharp,代码行数:4,代码来源:Context.cs


示例19: ResetSelection

        /// <summary>
        /// Reset (clear) the Selection.
        /// </summary>
        /// <param name="selectionSurface"></param>
        /// <param name="imageSize"></param>
        public void ResetSelection(Surface selectionSurface, Gdk.Size imageSize)
        {
            using (Cairo.Context g = new Cairo.Context(selectionSurface))
            {
                SelectionPath = g.CreateRectanglePath(new Rectangle(0, 0, imageSize.Width, imageSize.Height));
            }

            SelectionPolygons.Clear();
        }
开发者ID:bodicsek,项目名称:Pinta,代码行数:14,代码来源:DocumentSelection.cs


示例20: SetFill

 public static void SetFill(this Context ctx, Surface surface)
 {
     ctx.SetSource (surface);
 }
开发者ID:KULeuven-KRR,项目名称:IdpGie,代码行数:4,代码来源:CairoUtils.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Micro.ActionExecutionContext类代码示例发布时间:2022-05-24
下一篇:
C# Cairo.Rectangle类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap