[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-devel-list
Subject:    [Mono-dev] Mono.Cairo add Cairo.Surface.WriteToPng
From:       John Luke <john.luke () gmail ! com>
Date:       2005-08-30 19:40:43
Message-ID: 1125430844.7662.8.camel () localhost ! localdomain
[Download RAW message or body]

Hello,
	Another small patch for Mono.Cairo to write a surface to a png along
with an example to test it with.

["oldapi.cs" (oldapi.cs)]

using System;
using Cairo;

class T
{
	static void Main ()
	{
		Surface s = Surface.CreateForImage (Format.ARGB32, 400, 400);
		Graphics g = new Graphics (s);
		g.LineWidth = 15;
		g.MoveTo (new PointD (200, 100));
		g.LineTo (new PointD (300, 300));
		g.RelLineTo (new PointD (-200, 0));
		g.ClosePath ();
		g.Stroke ();

		s.WriteToPng ("test.png");
	}
}

["write_to_png.patch" (write_to_png.patch)]

Index: Mono.Cairo/Cairo.cs
===================================================================
--- Mono.Cairo/Cairo.cs	(revision 49138)
+++ Mono.Cairo/Cairo.cs	(working copy)
@@ -396,6 +396,9 @@
                 [DllImport (CairoImp)]                
                 public static extern void cairo_surface_destroy (IntPtr surface);
 
+                [DllImport (CairoImp)]                
+                public static extern void cairo_surface_write_to_png (IntPtr surface, string filename);
+
                 //
                 // Matrix
                 //
Index: Mono.Cairo/Surface.cs
===================================================================
--- Mono.Cairo/Surface.cs	(revision 49138)
+++ Mono.Cairo/Surface.cs	(working copy)
@@ -193,6 +193,11 @@
 		{
 			CairoAPI.cairo_surface_destroy (surface);
 		}
+
+		public void WriteToPng (string filename)
+		{
+			CairoAPI.cairo_surface_write_to_png (surface, filename);
+		}
 		
                 public IntPtr Pointer {
                         get { return surface; }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49138)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2005-08-30  John Luke  <john.luke@gmail.com>
+
+	* Mono.Cairo/Cairo.cs: add import for
+	cairo_surface_write_to_png
+	* Mono.Cairo/Surface.cs: add WriteToPng method
+
 2005-08-12 Hisham Mardam Bey <hisham.mardambey@gmail.com>
         * Added xlib surface size / font size functions
         * Added font matrix setting


_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic