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


C# Cairo.Surface类代码示例

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


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


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