Bläddra i källkod

2003-08-24 Duncan Mak <[email protected]>

	* System.Drawing.dll.sources: Add Cairo implementation.

2003-08-24  Duncan Mak  <[email protected]>

	Initial checkin of System.Drawing.XrImpl ported to use Cairo.

	* Graphics.cs (DrawCurve):
	(DrawImageUnscaled):
	(IsVisible):Implement the overloads in terms of the other overloads.

	(FillClosedCurve): Implement the simple APIs, the default tension
	is 0.5, the default FillMode is FillMode.Alternate.

	* cairo.cs: A copy of the CairoAPI class from the Mono.Cairo
	assembly, with some method parameter/return type changed to better
	fit the usage within System.Drawing.

	* gdk-helpers.cs: Emulate some of Gdk.Pixbuf's API here,
	basically the same as XrImpl's GDKfunctions.cs, but the names of
	the functions are nicer, with the help of the DllImportAttribute's
	EntryPoint field.

svn path=/trunk/mcs/; revision=17546
Duncan Mak 22 år sedan
förälder
incheckning
29eb433c52

+ 4 - 0
mcs/class/System.Drawing/ChangeLog

@@ -1,3 +1,7 @@
+2003-08-24  Duncan Mak  <[email protected]>
+
+	* System.Drawing.dll.sources: Add Cairo implementation.
+
 2003-07-23  Peter Williams  <[email protected]>
 
 	* System.Drawing.dll.sources: Add Pens.cs

+ 9 - 0
mcs/class/System.Drawing/System.Drawing.dll.sources

@@ -58,6 +58,15 @@ System.Drawing/impl/ItfPen.cs
 System.Drawing/impl/ItfRegion.cs
 System.Drawing/impl/ItfSolidBrush.cs
 System.Drawing/impl/ItfTextureBrush.cs
+System.Drawing/impl/cairo/Bitmap.cs
+System.Drawing/impl/cairo/Font.cs
+System.Drawing/impl/cairo/Image.cs
+System.Drawing/impl/cairo/gdk-helpers.cs
+System.Drawing/impl/cairo/Graphics.cs
+System.Drawing/impl/cairo/Pen.cs
+System.Drawing/impl/cairo/SolidBrush.cs
+System.Drawing/impl/cairo/cairo.cs
+System.Drawing/impl/cairo/FontFamily.cs
 System.Drawing/impl/gtk/Bitmap.cs
 System.Drawing/impl/gtk/Image.cs
 System.Drawing/impl/wine/Bitmap.cs

+ 317 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/Bitmap.cs

@@ -0,0 +1,317 @@
+//
+// System.Drawing.Bitmap.cs
+//
+// (C) 2002/3 Ximian, Inc.  http://www.ximian.com
+// Author: Christian Meyer <[email protected]>
+//			Jason Perkins <[email protected]>
+//			Dennis Hayes <[email protected]>
+//	    Alexandre Pigolkine <[email protected]>
+//
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Drawing.Imaging;
+
+namespace System.Drawing.Cairo {
+
+        internal class BitmapFactory : IBitmapFactory
+        {
+                public IBitmap Bitmap (int width, int height)
+                {
+                        return new Bitmap (width, height);
+                }
+
+                public IBitmap Bitmap (int width, int height, System.Drawing.Graphics g)
+                {
+                        return new Bitmap (width, height, (Graphics) g.implementation);
+                }
+
+                public IBitmap Bitmap (int width, int height, System.Drawing.Imaging.PixelFormat format)
+                {
+                        return new Bitmap (width, height, format);
+                }
+
+                public IBitmap Bitmap (System.Drawing.Image original, Size newSize)
+                {
+                        return new Bitmap ((System.Drawing.Cairo.Image) original.implementation, newSize);
+                }
+
+                public IBitmap Bitmap (Stream stream, bool useIcm)
+                {
+                        return new Bitmap (stream);
+                }
+
+                public IBitmap Bitmap (string filename, bool useIcm)
+                {
+                        return new Bitmap (filename, useIcm);
+                }
+
+                public IBitmap Bitmap (Type type, string resource)
+                {
+                        return new Bitmap (type, resource);
+                }
+
+                public IBitmap Bitmap (int width, int height, int stride,
+                                System.Drawing.Imaging.PixelFormat format, IntPtr scan0)
+                {
+                        return new Bitmap (width, height, stride, format, scan0);
+                }
+        }
+
+        internal sealed class Bitmap : Image, IBitmap {
+
+                float horizontalResolution;
+                float verticalResolution;
+			
+                internal void CommonInit (int width, int height)
+                {
+                        CommonInit (width, height, true);
+                }
+
+                internal void CommonInit (int width, int height, bool allocNativeObject)
+                {
+                        size = new Size (width, height);
+                        imageFormat = ImageFormat.Bmp;
+                        switch( pixelFormat) {
+                        case PixelFormat.Format32bppArgb:
+                                cairo_format = Format.ARGB32;
+                                if (allocNativeObject)
+                                        state = Gdk.Pixbuf.New (0, true, 8, width, height);
+                                break;
+                        case PixelFormat.Format24bppRgb:
+                                cairo_format = Format.RGB24;
+                                if (allocNativeObject)
+                                        state = Gdk.Pixbuf.New (0, true, 8, width, height);
+                                break;
+                        default:
+                                throw new NotImplementedException ();
+                        }
+
+                        horizontalResolution = verticalResolution = 96.0F;
+                }
+			
+#region constructors
+                /// <summary>
+                /// Constructors
+                /// </summary>
+
+                internal Bitmap (int width, int height)
+                {
+                        pixelFormat = PixelFormat.Format32bppArgb;
+                        CommonInit (width, height);
+                }
+
+                internal Bitmap (int width, int height, Graphics g)
+                {
+                        // TODO: Get pixelFormat from g
+                        CommonInit (width,height);
+                        //TODO: use graphics to set vertial and horzontal resolution.
+                        //TODO: that is all the spec requires or desires
+                }
+
+                [MonoTODO]
+                internal Bitmap (int width, int height, PixelFormat format)
+                {
+                        this.pixelFormat = format;
+                        CommonInit (width, height);
+                }
+
+                internal Bitmap (Image origial)
+                {
+                        throw new NotImplementedException ();
+                        //this.original = original;
+                }
+			
+                unsafe void InitFromStream (Stream stream)
+                {
+                        InternalImageInfo info = System.Drawing.Image.Decode (stream);
+                        if (info != null) {
+                                imageFormat = info.RawFormat;
+                                pixelFormat = info.PixelFormat;
+                                CommonInit (info.Size.Width, info.Size.Height, false);
+                                if (pixelFormat == PixelFormat.Format32bppArgb) {
+                                        state = Gdk.Pixbuf.NewFromData (
+                                                info.UnmanagedImagePtr, Gdk.Colorspace.Rgb, true, 8,
+                                                ((IImage) this).Size.Width, ((IImage) this).Size.Height,
+                                                info.Stride, IntPtr.Zero, IntPtr.Zero);
+
+                                } else if (pixelFormat == PixelFormat.Format24bppRgb) {
+                                        info.ChangePixelFormat (PixelFormat.Format32bppArgb);
+                                        state = Gdk.Pixbuf.NewFromData (
+                                                info.UnmanagedImagePtr, Gdk.Colorspace.Rgb, true, 8,
+                                                ((IImage) this).Size.Width, ((IImage) this).Size.Height,
+                                                info.Stride, IntPtr.Zero, IntPtr.Zero);
+
+                                } else {
+                                        throw new NotImplementedException();
+                                }
+                                // FIXME: It is not safe to dispose the info here
+                                // Memory leak!!!
+                                //info.Dispose();
+                        }
+                }
+			
+                internal Bitmap (Stream stream)
+                        : this (stream, false)
+                {
+                }
+
+
+                internal Bitmap (string filename)
+                        : this (filename, false)
+                {
+                }
+
+                internal Bitmap (Image original, Size newSize)
+                {
+                        throw new NotImplementedException ();
+                        //this.original = original;
+                        //this.newSize = newSize;
+                }
+
+                internal Bitmap (Stream stream, bool useIcm)
+                {
+                        InitFromStream(stream);
+                }
+
+                internal Bitmap (string filename, bool useIcm)
+                {
+                        FileStream file = new FileStream(filename, FileMode.Open);
+                        InitFromStream(file);
+                        file.Close();
+                }
+
+                internal Bitmap (Type type, string resource)
+                {
+                        throw new NotImplementedException ();
+                        //this.type = type;
+                        //this.resource = resource;
+                }
+
+                internal Bitmap (Image original, int width, int heigth)
+                {
+                        throw new NotImplementedException ();
+                        //this.original = original;
+                        //this.width = width;
+                        //this.heigth = heigth;
+                }
+
+
+                internal Bitmap (
+                        int width, int height, int stride,
+                        PixelFormat format, IntPtr scan0)
+                {
+                        throw new NotImplementedException ();
+                        //this.width = width;
+                        //this.heigth = heigth;
+                        //this.stride = stride;
+                        //this.format = format;
+                        //this.scan0 = scan0;
+                }
+#endregion
+
+                // methods
+                Color IBitmap.GetPixel (int x, int y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IBitmap.SetPixel (int x, int y, Color color)
+                {
+                        throw new NotImplementedException ();
+                }
+                IBitmap IBitmap.Clone (Rectangle rect,PixelFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+		
+                IBitmap IBitmap.Clone (RectangleF rect, PixelFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public static Bitmap FromHicon (IntPtr hicon) {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public static Bitmap FromResource (IntPtr hinstance, string bitmapName)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                IntPtr IBitmap.GetHbitmap ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                IntPtr IBitmap.GetHbitmap (Color background)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                IntPtr IBitmap.GetHicon ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+
+                [MonoTODO]
+                BitmapData IBitmap.LockBits (Rectangle rect, ImageLockMode flags, PixelFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IBitmap.MakeTransparent ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IBitmap.MakeTransparent (Color transparentColor)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IBitmap.SetResolution (float xDpi, float yDpi)
+                {
+                        horizontalResolution = xDpi;
+                        verticalResolution = yDpi;
+                }
+		
+                //Fixme: gtk should be inherited from Image
+                PixelFormat IImage.PixelFormat {
+                        get {
+                                return pixelFormat;
+                        }
+                }
+
+                void IBitmap.UnlockBits (BitmapData bitmapdata)
+                {
+                        // nothing to do!
+                }
+		
+                // properties
+                // needs to be done ###FIXME###
+
+
+                /// <summary>
+                /// Methods 
+                /// </summary>
+                protected override void Dispose (bool disposing)
+                {
+                        if (selected_into_graphics == null) 
+                                Gdk.Pixbuf.Finalize (state);			
+
+                        base.Dispose(disposing);
+                }
+			
+                //FIXME: included with gtk code. should be inherited from Image.
+                //		[MonoTODO]
+                //		public override void RotateFlip (RotateFlipType rotateFlipType) {
+                //			throw new NotImplementedException();
+                //		}
+		
+        }
+}
+

+ 425 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/Cairo.cs

@@ -0,0 +1,425 @@
+//
+// Cairo.cs
+//
+// Author: Duncan Mak ([email protected])
+//
+// (C) Ximian, Inc. 2003
+//
+// This is a simplistic binding of the Cairo API to C#. All functions
+// in cairo.h are transcribed into their C# equivelants and all
+// enumerations are also listed here.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Cairo {
+
+	public class Cairo
+        {
+                const string CairoImp = "cairo";
+                //
+                // Manipulating state objects
+                //
+		[DllImport (CairoImp)]
+		public static extern IntPtr cairo_create ();
+
+		[DllImport (CairoImp)]
+		public static extern IntPtr cairo_destroy (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_save (IntPtr cr);                
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_restore (IntPtr cr);
+
+                //
+                // Modify state
+                //
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_target_surface (IntPtr cr, IntPtr surface);
+                                
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_target_image (
+                        IntPtr cr, string data, Cairo.Format format, int width, int height, int stride);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_target_drawble (IntPtr cr, IntPtr dpy, ulong drawable);
+                
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op);
+
+       		[DllImport (CairoImp)]
+		public static extern void cairo_set_rgb_color (IntPtr cr, double red, double green, double blue);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_alpha (IntPtr cr, double alpha);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_pattern (IntPtr cr, IntPtr pattern);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_tolerence (IntPtr cr, double tolerance);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_line_width (IntPtr cr, double width);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_line_cap (IntPtr cr, Cairo.LineCap line_cap);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_line_join (IntPtr cr, Cairo.LineJoin line_join);
+
+       		[DllImport (CairoImp)]
+		public static extern void cairo_set_dash (IntPtr cr, double [] dashes, int ndash, double offset);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_miter_limit (IntPtr cr, double limit);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_translate (IntPtr cr, double tx, double ty);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_scale (IntPtr cr, double sx, double sy);
+
+                [DllImport (CairoImp)]                
+                public static extern void cairo_rotate (IntPtr cr, double angle);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_concat_matrix (IntPtr cr, IntPtr matrix);                
+                
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_matrix (IntPtr cr, IntPtr matrix);
+                
+                [DllImport (CairoImp)]
+                public static extern void cairo_default_matrix (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_identity_matrix (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_transform_point (IntPtr cr, ref double x, ref double y);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_transform_distance (IntPtr cr, ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_inverse_transform_point (IntPtr cr, ref double x, ref double y);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_inverse_transform_distance (IntPtr cr, ref double dx, ref double dy);
+
+                //
+                // Path creation
+                //
+		[DllImport (CairoImp)]
+		public static extern void cairo_new_path (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_move_to (IntPtr cr, double x, double y);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_line_to (IntPtr cr, double x, double y);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_curve_to (
+                        IntPtr cr, double x1, double y1, double x2, double y2, double x3, double y3);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rel_move_to (IntPtr cr, double dx, double dy);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rel_line_to (IntPtr cr, double dx, double dy);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rel_curve_to (
+                        IntPtr cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rectangle (IntPtr cr, double x, double y, double width, double height);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_close_path (IntPtr cr);
+
+                //
+                // Painting
+                //
+                [DllImport (CairoImp)]
+                public static extern void cairo_stroke (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_fill (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_clip (IntPtr cr);
+
+                //
+                // Font / Text
+                //
+                [DllImport (CairoImp)]
+                public static extern void cairo_select_font (IntPtr cr, string key);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_scale_font (IntPtr cr, double scale);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_transform_font (
+                        IntPtr cr, double a, double b, double c, double d);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_text_extents (
+                        IntPtr cr, string utf8,
+                        ref double x, ref double y,
+                        ref double width, ref double height,
+                        ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_show_text (IntPtr cr, string utf8);
+
+                //
+                // Image
+                //                
+                [DllImport (CairoImp)]
+                public static extern void cairo_show_surface (IntPtr cr, IntPtr surface, int width, int height);
+
+                //
+                // query
+                //                                
+                [DllImport (CairoImp)]
+		public static extern Cairo.Operator cairo_get_operator (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_get_rgb_color (
+                        IntPtr cr, out double red, out double green, out double blue);
+
+                [DllImport (CairoImp)]
+                public static extern double cairo_get_alpha (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern double cairo_get_tolerence (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_get_current_point (
+                        IntPtr cr, out double x, out double y);
+
+		[DllImport (CairoImp)]
+		public static extern Cairo.FillRule cairo_get_fill_rule (IntPtr cr);
+
+                [DllImport (CairoImp)]
+		public static extern double cairo_get_line_width (IntPtr cr);
+
+                [DllImport (CairoImp)]
+		public static extern LineCap cairo_get_line_cap (IntPtr cr);
+
+       		[DllImport (CairoImp)]
+		public static extern LineJoin cairo_get_line_join (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern double cairo_get_miter_limit (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_get_matrix (
+                        IntPtr cr,
+                        out double a, out double b,
+                        out double c, out double d,
+                        out double tx, out double ty);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_get_target_surface (IntPtr cr);
+
+                //
+                // Error status queries
+                //
+                [DllImport (CairoImp)]
+                public static extern Cairo.Status cairo_get_status (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern string cairo_get_status_string (IntPtr cr);
+
+                //
+                // Surface Manipulation
+                //
+                
+                [DllImport (CairoImp)]
+                public static extern IntPtr cairo_surface_create_for_drawable (
+                        IntPtr display, ulong drawable, IntPtr visual,
+                        Cairo.Format format, ulong colormap);
+
+                [DllImport (CairoImp)]                
+                public static extern IntPtr cairo_surface_create_for_image (
+                        string data, Cairo.Format format, int width, int height, int stride);
+
+                [DllImport (CairoImp)]
+                public static extern IntPtr cairo_surface_create_similar (
+                        IntPtr surface, Cairo.Format format, int width, int height);
+
+                [DllImport (CairoImp)]                
+                public static extern IntPtr cairo_surface_create_similar_solid (
+                        IntPtr surface, Cairo.Format format,
+                        int width, int height, double red, double green, double blue, double alpha);
+
+                [DllImport (CairoImp)]                
+                public static extern void cairo_surface_destroy (IntPtr surface);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_put_image (
+                        IntPtr surface, string data, int width, int height, int stride);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_set_repeat (
+                        IntPtr surface, int repeat);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_set_matrix (
+                        IntPtr surface, IntPtr matrix);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_get_matrix (
+                        IntPtr surface, ref IntPtr matrix);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_set_filter (
+                        IntPtr surface, Cairo.Filter filter);
+
+                //
+                // Matrix
+                //
+
+                [DllImport (CairoImp)]                
+                public static extern IntPtr cairo_matrix_create ();
+
+                [DllImport (CairoImp)]                
+                public static extern void cairo_matrix_destroy (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_copy (
+                        IntPtr matrix, out IntPtr other);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_set_identity (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_set_affine (
+                        IntPtr matrix,
+                        double a, double b, double c, double d, double tx, double ty);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_get_affine (
+                        IntPtr matrix,
+                        out double a, out double b, out double c, out double d, out double tx, out double ty);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_translate (
+                        IntPtr matrix, double tx, double ty);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_scale (
+                        IntPtr matrix, double sx, double sy);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_rotate (
+                        IntPtr matrix, double radians);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_invert (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_multiply (
+                        out IntPtr result, IntPtr a, IntPtr b);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_transform_distance (
+                        IntPtr matrix, ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_transform_point (
+                        IntPtr matrix, ref double x, ref double y);
+        }
+
+        //
+        // Enumerations
+        //
+        public enum Format {
+                ARGB32 = 0,
+                RGB24 = 1,
+                A8 = 2,
+                A1 = 4
+        }
+
+        public enum Operator {
+                Clear = 0,
+                Src = 1,
+                Dst = 2,
+                Over = 3,
+                OverReverse = 4,
+                In = 5,
+                InReverse = 6,
+                Out = 7,
+                OutReverse = 8,
+                Atop = 9,
+                AtopReverse = 10,
+                Xor = 11,
+                Add = 12,
+                Saturate = 13,
+                
+                DisjointClear = 16,
+                DisjointSrc = 17,
+                DisjointDst = 18,
+                DisjointOver = 19,
+                DisjointOverReverse = 20,
+                DisjointIn = 21,
+                DisjointInReverse = 22,
+                DisjointOut = 23,
+                DisjointOutReverse = 24,
+                DisjointAtop = 25,
+                DisjointAtopReverse = 26,
+                DisjointXor = 27,
+
+                ConjointClear = 32,
+                ConjointSrc = 33,
+                ConjointDst = 34,
+                ConjointOver = 35,
+                ConjointOverReverse = 36,
+                ConjointIn = 37,
+                ConjointInReverse = 38,
+                ConjointOut = 39,
+                ConjointOutReverse = 40,
+                ConjointAtop = 41,
+                ConjointAtopReverse = 42,
+                ConjointXor = 43
+        }
+
+        public enum FillRule {
+                Winding,
+                EvenOdd
+        }
+
+        public enum LineCap {
+                Butt, Round, Square
+        }
+
+        public enum LineJoin {
+                Miter, Round, Bevel
+        }
+
+        public enum Status {
+                Success = 0,
+                NoMemory,
+                InvalidRestore,
+                InvalidPopGroup,
+                NoCurrentPoint,
+                InvalidMatrix
+        }
+
+        public enum Filter {
+                Fast,
+                Good,
+                Best,
+                Nearest,
+                Bilinear
+        }
+}

+ 19 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/ChangeLog

@@ -0,0 +1,19 @@
+2003-08-24  Duncan Mak  <[email protected]> 		
+
+	Initial checkin of System.Drawing.XrImpl ported to use Cairo.
+
+	* Graphics.cs (DrawCurve):
+	(DrawImageUnscaled): 
+	(IsVisible):Implement the overloads in terms of the other overloads.
+
+	(FillClosedCurve): Implement the simple APIs, the default tension
+	is 0.5, the default FillMode is FillMode.Alternate.
+
+	* cairo.cs: A copy of the CairoAPI class from the Mono.Cairo
+	assembly, with some method parameter/return type changed to better
+	fit the usage within System.Drawing.
+
+	* gdk-helpers.cs: Emulate some of Gdk.Pixbuf's API here,
+	basically the same as XrImpl's GDKfunctions.cs, but the names of
+	the functions are nicer, with the help of the DllImportAttribute's
+	EntryPoint field.

+ 162 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/Font.cs

@@ -0,0 +1,162 @@
+//
+// System.Drawing.Font.cs
+//
+// Author:
+//   Alexandre Pigolkine ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+using System.Drawing;
+
+namespace System.Drawing.Cairo {
+
+        internal class FontFactory : IFontFactory
+        {
+                        
+                IFont IFontFactory.Font (FontFamily family,
+                                float emSize, FontStyle style,
+                                GraphicsUnit unit, byte charSet, bool isVertical) {
+
+                        return new Font (family, emSize, style, unit, charSet, isVertical);
+                }
+
+                IFont IFontFactory.Font (
+                        string familyName, float emSize, FontStyle style,
+                        GraphicsUnit unit, byte charSet, bool isVertical) {
+
+                        return new Font (familyName, emSize, style, unit, charSet, isVertical);
+                }
+
+                IFont IFontFactory.FromHfont(IntPtr font) {
+                        return Win32Impl.Font.FromHfont(font);
+                }
+        }
+
+        internal sealed class Font : MarshalByRefObject, IFont
+        {
+                FontFamily fontFamily;
+                byte gdiCharSet;
+                bool gdiVerticalFont;
+                int  height;
+                string name;
+                float size;
+                float sizeInPoints;
+                FontStyle style;
+                GraphicsUnit unit;
+			
+                public void Dispose () {
+                }
+
+                public static Font FromHfont(IntPtr font)
+                {
+                        //FIXME: how to get those values ?
+                        Font result = new Font("Arial", (float)12.0, FontStyle.Regular, GraphicsUnit.Point, (byte)0, false);
+                        return result;
+                }
+
+                public IntPtr ToHfont () { throw new NotImplementedException(); }
+
+                public Font(FontFamily family, float size, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical){
+                        fontFamily = family;
+                        this.size = size;
+                        this.style = style;
+                        this.unit = unit;
+                        this.gdiCharSet = charSet;
+                        this.gdiVerticalFont = isVertical;
+                }
+
+                public Font(string familyName, float size, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical){
+                        fontFamily = new FontFamily(familyName);
+                        this.size = size;
+                        this.style = style;
+                        this.unit = unit;
+                        this.gdiCharSet = charSet;
+                        this.gdiVerticalFont = isVertical;
+                }
+
+                internal void initialize (IntPtr cr)
+                {
+                        Cairo.cairo_select_font (cr, fontFamily.Name + "--" + size);
+                }
+			
+                public bool Bold {
+                        get {
+                                return (style & FontStyle.Bold) == FontStyle.Bold;
+                        }
+                }
+		
+                public FontFamily FontFamily {
+                        get {
+                                return fontFamily;
+                        }
+                }
+		
+                public byte GdiCharSet {
+                        get {
+                                return gdiCharSet;
+                        }
+                }
+		
+                public bool GdiVerticalFont {
+                        get {
+                                return gdiVerticalFont;
+                        }
+                }
+		
+                public int Height {
+                        get {
+                                return height;
+                        }
+                }
+
+                public bool Italic {
+                        get {
+                                return (style & FontStyle.Italic) == FontStyle.Italic;
+                        }
+                }
+
+                public string Name {
+                        get {
+                                return name;
+                        }
+                }
+
+                public float Size {
+                        get {
+                                return size;
+                        }
+                }
+
+                public float SizeInPoints {
+                        get {
+                                return sizeInPoints;
+                        }
+                }
+
+                public bool Strikeout {
+                        get {
+                                return (style & FontStyle.Strikeout) == FontStyle.Strikeout;
+                        }
+                }
+		
+                public FontStyle Style {
+                        get {
+                                return style;
+                        }
+                }
+
+                public bool Underline {
+                        get {
+                                return (style & FontStyle.Underline) == FontStyle.Underline;
+                        }
+                }
+
+                public GraphicsUnit Unit {
+                        get {
+                                return unit;
+                        }
+                }
+        }
+}

+ 92 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/FontFamily.cs

@@ -0,0 +1,92 @@
+//
+// System.Drawing.XrImpl.FontFamily.cs
+//
+// Author:
+//   Alexandre Pigolkine ([email protected])
+//
+//
+
+using System;
+using System.Drawing;
+using System.Drawing.Text;
+
+namespace System.Drawing.Cairo {
+
+        internal class FontFamilyFactory : IFontFamilyFactory {
+
+                IFontFamily IFontFamilyFactory.FontFamily(GenericFontFamilies genericFamily){
+                        return new CairoFontFamily (genericFamily);
+                }
+
+                IFontFamily IFontFamilyFactory.FontFamily(string familyName){
+                        return new CairoFontFamily (familyName);
+                }
+			
+                IFontFamily IFontFamilyFactory.FontFamily( string familyName, FontCollection collection){
+                        return new CairoFontFamily (familyName,collection);
+                }
+			
+                IFontFamily[] IFontFamilyFactory.GetFamilies(System.Drawing.Graphics graphics) { 
+                        throw new NotImplementedException();
+                }		
+			
+        }
+
+        internal class CairoFontFamily : MarshalByRefObject, IFontFamily
+        {
+                string name;
+                static CairoFontFamily genericMonospace;
+                static CairoFontFamily genericSansSerif;
+                static CairoFontFamily genericSerif;
+			
+                public CairoFontFamily (GenericFontFamilies genericFamily)
+                {
+                        throw new NotImplementedException();
+                }
+		
+                public CairoFontFamily (string familyName)
+                {
+                        name = familyName;
+                }
+		
+                public CairoFontFamily (string familyName, FontCollection collection)
+                {
+                        name = familyName;
+                }
+		
+                public string Name {
+                        get {
+                                return name;
+                        }
+                }
+		
+                public int GetCellAscent (FontStyle style)
+                {
+                        return 0;
+                }
+		
+                public int GetCellDescent (FontStyle style)
+                {
+                        return 0;
+                }
+		
+                public int GetEmHeight (FontStyle style)
+                {
+                        return 0;
+                }
+		
+                public int GetLineSpacing (FontStyle style)
+                {
+                        return 0;
+                }
+		
+                public bool IsStyleAvailable (FontStyle style)
+                {
+                        return false;
+                }
+			
+                public void Dispose()
+                {
+                }
+        }
+}

+ 1718 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/Graphics.cs

@@ -0,0 +1,1718 @@
+//v
+// System.Drawing.Bitmap.cs (Cairo implementation)
+//
+// (C) 2003 Ximian, Inc.  http://www.ximian.com
+//
+// Author: Duncan Mak ([email protected])
+//
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Imaging;
+using System.Drawing.Text;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Cairo {
+
+        internal class GraphicsFactory : IGraphicsFactory {
+
+                public System.Drawing.IGraphics Graphics (IntPtr nativeGraphics)
+                {
+                        return new Graphics (nativeGraphics);
+                }
+
+                public System.Drawing.IGraphics FromImage (System.Drawing.Image image)
+                {
+                        return System.Drawing.Cairo.Graphics.FromImage (image);
+                }
+
+                public System.Drawing.IGraphics FromHwnd (IntPtr hwnd)
+                {
+                        return System.Drawing.Cairo.Graphics.FromHwnd (hwnd);
+                }
+        }
+
+
+        [ComVisible (false)]
+        internal sealed class Graphics : MarshalByRefObject, IGraphics
+        {
+                public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
+                                int flags,
+                                int dataSize,
+                                IntPtr data,
+                                PlayRecordCallback callbackData);
+			
+                public delegate bool DrawImageAbort (IntPtr callbackData);
+
+                internal enum GraphicsType {
+                        FromHDC, FromHwnd, FromImage
+                };
+
+                internal GraphicsType type;
+                internal IntPtr state = IntPtr.Zero;
+                
+                internal IntPtr initial_hwnd = IntPtr.Zero;
+                internal System.Drawing.Cairo.Image initialized_from_image = null;
+
+                internal const double C1 = 0.552; // this is some *magic* number
+
+                internal Graphics (IntPtr nativeGraphics)
+                {
+                        state = nativeGraphics;
+                }
+
+#region Converters
+                internal static Pen ConvertPen (System.Drawing.Pen pen) 
+                {
+                        return pen.implementation as System.Drawing.Cairo.Pen;
+                }
+
+                internal static Brush ConvertBrush (System.Drawing.Brush brush) 
+                {
+                        return brush.implementation as Brush;
+                }
+
+                internal static Image ConvertImage (System.Drawing.Image image) 
+                {
+                        return image.implementation as System.Drawing.Cairo.Image;
+                }
+			
+                internal static Font ConvertFont (System.Drawing.Font font) 
+                {
+                        return font.implementation as System.Drawing.Cairo.Font;
+                }
+#endregion
+
+                [MonoTODO]
+                void IGraphics.AddMetafileComment (byte [] data)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                GraphicsContainer IGraphics.BeginContainer ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                GraphicsContainer IGraphics.BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                GraphicsContainer IGraphics.BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.Clear (Color color)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IDisposable.Dispose ()
+                {
+                        switch (type) {
+                        case GraphicsType.FromHwnd:
+                                break;
+                        case GraphicsType.FromHDC:
+                                break;
+                        case GraphicsType.FromImage:
+                                Cairo.cairo_destroy (state);
+                                break;
+                        }
+                }
+
+                void IGraphics.DrawArc (System.Drawing.Pen pen, Rectangle rect, float startAngle, float sweepAngle)
+                {
+                        ((IGraphics) this).DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+                }
+
+                void IGraphics.DrawArc (System.Drawing.Pen pen, RectangleF rect, float startAngle, float sweepAngle)
+                {
+                        ((IGraphics) this).DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawArc (System.Drawing.Pen pen,
+                                float x, float y, float width, float height, float startAngle, float sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawArc (System.Drawing.Pen pen,
+                                int x, int y, int width, int height, int startAngle, int sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawBezier (System.Drawing.Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
+                {
+                        ((IGraphics) this).DrawBezier (pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
+                }
+
+                void IGraphics.DrawBezier (System.Drawing.Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
+                {
+                        ((IGraphics) this).DrawBezier (pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
+                }
+
+                void IGraphics.DrawBezier (System.Drawing.Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
+                {
+                        Pen cPen = ConvertPen (pen);
+                        cPen.initialize (state);
+
+                        Cairo.cairo_move_to (state, x1, y1);
+                        Cairo.cairo_curve_to (state, x2, y2, x3, y3, x4, y4);
+
+                        Cairo.cairo_stroke (state);
+                }
+
+                void IGraphics.DrawBeziers (System.Drawing.Pen pen, Point [] points)
+                {
+                        Pen cPen = ConvertPen (pen);
+                        cPen.initialize (state);
+
+                        Cairo.cairo_move_to (state, points [0].X, points [0].Y);
+
+                        for (int i = 1; i < points.Length; i += 3)
+                                Cairo.cairo_curve_to (
+                                        state,
+                                        points [i].X, points [i].Y,
+                                        points [i + 1].X, points [i + 1].Y,
+                                        points [i + 2].X, points [i + 2].Y);
+
+                        Cairo.cairo_stroke (state);
+                }
+
+                void IGraphics.DrawBeziers (System.Drawing.Pen pen, PointF [] points)
+                {
+                        Pen cPen = ConvertPen (pen);
+                        cPen.initialize (state);
+
+                        Cairo.cairo_move_to (state, points [0].X, points [0].Y);
+
+                        for (int i = 1; i < points.Length; i += 3)
+                                Cairo.cairo_curve_to (
+                                        state,
+                                        points [i].X, points [i].Y,
+                                        points [i + 1].X, points [i + 1].Y,
+                                        points [i + 2].X, points [i + 2].Y);
+
+                        Cairo.cairo_stroke (state);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawClosedCurve (System.Drawing.Pen pen, PointF [] points)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawClosedCurve (System.Drawing.Pen pen, Point [] points)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawClosedCurve (System.Drawing.Pen pen, Point [] points, float tension, FillMode fillmode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawClosedCurve (System.Drawing.Pen pen, PointF [] points, float tension, FillMode fillmode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, Point [] points)
+                {
+                        ((IGraphics) this).DrawCurve (pen, points, 0.5f);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, PointF [] points)
+                {
+                        ((IGraphics) this).DrawCurve (pen, points, 0.5f);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, PointF [] points, float tension)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, Point [] points, float tension)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, PointF [] points, int offset, int numberOfSegments)
+                {
+                        ((IGraphics) this).DrawCurve (pen, points, offset, numberOfSegments, 0.5f);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawCurve (System.Drawing.Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawEllipse (System.Drawing.Pen pen, Rectangle rect)
+                {
+                        ((IGraphics) this).DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
+                }
+
+                void IGraphics.DrawEllipse (System.Drawing.Pen pen, RectangleF rect)
+                {
+                        ((IGraphics) this).DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
+                }
+
+                void IGraphics.DrawEllipse (System.Drawing.Pen pen, int x, int y, int width, int height)
+                {
+                        ((IGraphics) this).DrawEllipse (pen, (float) x, (float) y, (float) width, (float) height);
+                }
+
+                void IGraphics.DrawEllipse (System.Drawing.Pen pen, float x, float y, float width, float height)
+                {
+                        double rx = width / 2;
+                        double ry = height / 2;
+                        double cx = x + rx;
+                        double cy = y + ry;
+
+                        Pen cPen = ConvertPen (pen);
+
+                        cPen.initialize (state);
+                        Cairo.cairo_move_to (state, cx + rx, cy);
+				
+                        // Do an approprimation of the ellipse by drawing a curve in each quatrant
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx + rx, cy - C1 * ry,
+                                cx + C1 * rx, cy - ry,
+                                cx, cy - ry);
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx - C1 * rx, cy - ry,
+                                cx - rx, cy - C1 * ry,
+                                cx - rx, cy);
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx - rx, cy + C1 * ry,
+                                cx - C1 * rx, cy + ry,
+                                cx, cy + ry);
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx + C1 * rx, cy + ry,
+                                cx + rx, cy + C1 * ry,
+                                cx + rx, cy);
+
+                        Cairo.cairo_close_path (state);
+                        Cairo.cairo_stroke (state);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawIcon (System.Drawing.Icon icon, Rectangle targetRect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawIcon (System.Drawing.Icon icon, int x, int y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawIconUnstretched (System.Drawing.Icon icon, Rectangle targetRect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, RectangleF rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, PointF point)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Point [] destPoints)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Point point)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, PointF [] destPoints)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, int x, int y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, float x, float y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, float x, float y, float width, float height)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, int x, int y, int width, int height)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback, int callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback, int callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, System.Drawing.Graphics.DrawImageAbort callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, System.Drawing.Graphics.DrawImageAbort callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImage (System.Drawing.Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, System.Drawing.Graphics.DrawImageAbort callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawImageUnscaled (System.Drawing.Image image, Point point)
+                {
+                        ((IGraphics) this).DrawImageUnscaled (image, point.X, point.Y);
+                }
+
+                void IGraphics.DrawImageUnscaled (System.Drawing.Image image, Rectangle rect)
+                {
+                        ((IGraphics) this).DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImageUnscaled (System.Drawing.Image image, int x, int y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawImageUnscaled (System.Drawing.Image image, int x, int y, int width, int height)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void DrawLine (Pen cPen, float x1, float y1, float x2, float y2) 
+                {
+                        cPen.initialize (state);
+                        Cairo.cairo_move_to (state, (double) x1, (double) y1);
+                        Cairo.cairo_line_to (state, (double) x2, (double) y2);
+                        Cairo.cairo_stroke (state);
+                }
+			
+                [MonoTODO]
+                void IGraphics.DrawLine (System.Drawing.Pen pen, PointF pt1, PointF pt2)
+                {
+                        DrawLine (ConvertPen (pen), pt1.X, pt1.Y, pt2.X, pt2.Y);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawLine (System.Drawing.Pen pen, Point pt1, Point pt2)
+                {
+                        DrawLine (ConvertPen (pen),
+                                        (float) pt1.X, (float) pt1.Y,
+                                        (float) pt2.X, (float) pt2.Y);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawLine (System.Drawing.Pen pen, int x1, int y1, int x2, int y2)
+                {
+                        DrawLine (ConvertPen (pen),
+                                        (float) x1, (float) y1,
+                                        (float) x2, (float) y2);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawLine (System.Drawing.Pen pen, float x1, float y1, float x2, float y2)
+                {
+                        DrawLine (ConvertPen (pen), x1, y1, x2, y2);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawLines (System.Drawing.Pen pen, PointF [] points)
+                {
+                        if (points.Length == 0)
+                                return;
+                        
+                        Pen cPen = ConvertPen (pen);
+                        cPen.initialize (state);
+                        Cairo.cairo_move_to (state, (double) points [0].X, (double) points [0].Y);
+                        
+                        if (points.Length == 1)
+                                Cairo.cairo_line_to (state, (double) points [0].X, (double) points [0].Y);
+
+                        else
+                                for (int i = 1; i < points.Length; i++)
+                                        Cairo.cairo_line_to (state, (double) points [i].X, (double) points [i].Y);
+
+                        Cairo.cairo_stroke (state);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawLines (System.Drawing.Pen pen, Point [] points)
+                {
+                        if (points.Length == 0)
+                                return;
+                        
+                        PointF [] pointsf = new PointF [points.Length];
+                        
+                        for (int i = 0; i < points.Length; i++)
+                                        pointsf [i] = new PointF (points [i].X, points [i].Y);
+
+                        ((IGraphics) this).DrawLines (pen, pointsf);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawPath (System.Drawing.Pen pen, GraphicsPath path)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawPie (System.Drawing.Pen pen, Rectangle rect, float startAngle, float sweepAngle)
+                {
+                        ((IGraphics) this).DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+                }
+
+                void IGraphics.DrawPie (System.Drawing.Pen pen, RectangleF rect, float startAngle, float sweepAngle)
+                {
+                        ((IGraphics) this).DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawPie (System.Drawing.Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawPie (System.Drawing.Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.DrawPolygon (System.Drawing.Pen pen, Point [] points)
+                {
+                        Pen cPen = ConvertPen (pen);
+
+                        cPen.initialize (state);
+                        Cairo.cairo_move_to (state, (double) points [0].X, (double) points [0].Y);
+
+                        for (int i = 1; i < points.Length; i ++)
+                                Cairo.cairo_line_to (state, (double) points [i].X, (double) points [i].Y);
+				
+                        Cairo.cairo_close_path (state);
+                        Cairo.cairo_stroke (state);
+                }
+
+                void IGraphics.DrawPolygon (System.Drawing.Pen pen, PointF [] points)
+                {
+                        Pen cPen = ConvertPen (pen);
+
+                        cPen.initialize (state);
+
+                        for (int i = 0; i < points.Length; i += 2)
+                                ((IGraphics) this).DrawLine (pen, points [i], points [i + 1]);
+				
+                        Cairo.cairo_close_path (state);
+                        Cairo.cairo_stroke (state);
+                }
+
+                void IGraphics.DrawRectangle (System.Drawing.Pen pen, Rectangle rect)
+                {
+                        DrawRectangle (
+                                ConvertPen (pen),
+                                (double) rect.Left, (double) rect.Top,
+                                (double) rect.Width, (double)rect.Height);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawRectangle (System.Drawing.Pen pen, float x, float y, float width, float height)
+                {
+                        DrawRectangle (
+                                ConvertPen (pen),
+                                (double) x, (double) y,
+                                (double) width, (double) height);
+                }
+
+                void DrawRectangle (Pen cPen, double x, double y, double width, double height)
+                {
+                        cPen.initialize (state);
+
+                        Cairo.cairo_move_to (state, x, y);
+                        Cairo.cairo_line_to (state, x + width, y);
+                        Cairo.cairo_line_to (state, x + width, y + height);
+                        Cairo.cairo_line_to (state, x, y + height);
+                        Cairo.cairo_line_to (state, x, y);
+                        Cairo.cairo_stroke (state);
+                }
+
+                void IGraphics.DrawRectangle (System.Drawing.Pen pen, int x, int y, int width, int height)
+                {
+                        DrawRectangle (
+                                ConvertPen (pen),
+                                (double) x, (double) y,
+                                (double) width, (double) height);
+                }
+
+                void IGraphics.DrawRectangles (System.Drawing.Pen pen, RectangleF [] rects)
+                {
+                        foreach (RectangleF rc in rects) 
+                                DrawRectangle (
+                                        ConvertPen (pen),
+                                        (double) rc.Left, (double) rc.Top,
+                                        (double) rc.Width, (double) rc.Height);
+                }
+
+                void IGraphics.DrawRectangles (System.Drawing.Pen pen, Rectangle [] rects)
+                {
+                        foreach (RectangleF rc in rects) 
+                                DrawRectangle (
+                                        ConvertPen (pen),
+                                        (double) rc.Left, (double) rc.Top,
+                                        (double) rc.Width, (double) rc.Height);
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, RectangleF layoutRectangle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, PointF point)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, PointF point, StringFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, RectangleF layoutRectangle, StringFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y)
+                {
+                        Font cFont = ConvertFont (font);
+                        cFont.initialize (state);
+                        Brush cBrush = ConvertBrush (brush);
+                        if (cBrush is SolidBrush) {
+                                SolidBrush cSolidBrush = cBrush as SolidBrush;
+                                cSolidBrush.initialize (state);
+                                Cairo.cairo_move_to (state, (double) x, (double) y);
+                                Cairo.cairo_show_text (state, s);
+                        }
+                }
+
+                [MonoTODO]
+                void IGraphics.DrawString (string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, StringFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EndContainer (GraphicsContainer container)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point [] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF [] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF [] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point [] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point [] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF [] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.ExcludeClip (Rectangle rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.ExcludeClip (System.Drawing.Region region)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.FillClosedCurve (System.Drawing.Brush brush, PointF [] points)
+                {
+                        ((IGraphics) this).FillClosedCurve (brush, points, FillMode.Alternate, 0.5f);
+                }
+
+                void IGraphics.FillClosedCurve (System.Drawing.Brush brush, Point [] points)
+                {
+                        ((IGraphics) this).FillClosedCurve (brush, points, FillMode.Alternate, 0.5f);
+                }
+
+                void IGraphics.FillClosedCurve (System.Drawing.Brush brush, PointF [] points, FillMode fillmode)
+                {
+                        ((IGraphics) this).FillClosedCurve (brush, points, fillmode, 0.5f);
+                }
+
+                void IGraphics.FillClosedCurve (System.Drawing.Brush brush, Point [] points, FillMode fillmode)
+                {
+                        ((IGraphics) this).FillClosedCurve (brush, points, fillmode, 0.5f);
+                }
+
+                [MonoTODO]
+                void IGraphics.FillClosedCurve (System.Drawing.Brush brush, PointF [] points, FillMode fillmode, float tension)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.FillClosedCurve (System.Drawing.Brush brush, Point [] points, FillMode fillmode, float tension)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.FillEllipse (System.Drawing.Brush brush, Rectangle rect)
+                {
+                        ((IGraphics) this).FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
+                }
+
+                void IGraphics.FillEllipse (System.Drawing.Brush brush, RectangleF rect)
+                {
+                        ((IGraphics) this).FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
+                }
+
+                void IGraphics.FillEllipse (System.Drawing.Brush brush, float x, float y, float width, float height)
+                {				 
+                        double rx = width / 2;
+                        double ry = height / 2;
+                        double cx = x + rx;
+                        double cy = y + ry;
+				
+                        Brush cBrush = ConvertBrush (brush);
+                        // cBrush.initialize (state);
+                        Cairo.cairo_move_to (state, cx + rx, cy);
+
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx + rx, cy - C1 * ry,
+                                cx + C1 * rx, cy - ry,
+                                cx, cy - ry);
+
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx - C1 * rx, cy - ry,
+                                cx - rx, cy - C1 * ry,
+                                cx - rx, cy);
+
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx - rx, cy + C1 * ry,
+                                cx - C1 * rx, cy + ry,
+                                cx, cy + ry);
+
+                        Cairo.cairo_curve_to (
+                                state,
+                                cx + C1 * rx, cy + ry,
+                                cx + rx, cy + C1 * ry,
+                                cx + rx, cy);
+
+                        Cairo.cairo_close_path (state);
+				
+                        Cairo.cairo_fill (state);
+                }
+
+                void IGraphics.FillEllipse (System.Drawing.Brush brush, int x, int y, int width, int height)
+                {
+                        ((IGraphics) this).FillEllipse (brush, (float) x, (float) y, (float) width, (float) height);
+                }
+
+                [MonoTODO]
+                void IGraphics.FillPath (System.Drawing.Brush brush, GraphicsPath path)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.FillPie (System.Drawing.Brush brush, Rectangle rect, float startAngle, float sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.FillPie (System.Drawing.Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.FillPie (System.Drawing.Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.FillPolygon (System.Drawing.Brush brush, PointF [] points)
+                {
+                        ((IGraphics) this).FillPolygon (brush, points, FillMode.Alternate);
+                }
+
+                void IGraphics.FillPolygon (System.Drawing.Brush brush, Point [] points)
+                {
+                        ((IGraphics) this).FillPolygon (brush, points, FillMode.Alternate);
+                }
+
+                [MonoTODO]
+                void IGraphics.FillPolygon (System.Drawing.Brush brush, Point [] points, FillMode fillMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.FillPolygon (System.Drawing.Brush brush, PointF [] points, FillMode fillMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                void IGraphics.FillRectangle (System.Drawing.Brush brush, RectangleF rect)
+                {
+                        FillRectangle (ConvertBrush (brush), rect.Left, rect.Top, rect.Width, rect.Height);
+                }
+
+                void IGraphics.FillRectangle (System.Drawing.Brush brush, Rectangle rect)
+                {
+                        FillRectangle (
+                                ConvertBrush (brush),
+                                (float) rect.Left, (float) rect.Top,
+                                (float) rect.Width, (float) rect.Height);
+                }
+
+                void FillRectangle (Brush brush, RectangleF rect)
+                {
+                        FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
+                }
+
+                void FillRectangle (Brush brush, Rectangle rect)
+                {
+                        FillRectangle (
+                                brush,
+                                (float) rect.Left, (float) rect.Top,
+                                (float) rect.Width, (float) rect.Height);
+                }
+
+                void FillRectangle (Brush brush, float x, float y, float width, float height)
+                {
+                        if (brush is SolidBrush) {
+                                SolidBrush cBrush = brush as SolidBrush;
+                                cBrush.initialize (state);
+                                Cairo.cairo_rectangle (state, x, y, width, height);
+                                Cairo.cairo_fill (state);
+                        }
+                }
+
+                void IGraphics.FillRectangle (System.Drawing.Brush brush, int x, int y, int width, int height)
+                {
+                        FillRectangle (brush, (float)x, (float)y, (float)width, (float)height);
+                }
+
+                void IGraphics.FillRectangle (System.Drawing.Brush brush, float x, float y, float width, float height)
+                {
+                        FillRectangle (ConvertBrush (brush), x, y, width, height);
+                }
+
+                [MonoTODO]
+                void IGraphics.FillRectangles (System.Drawing.Brush brush, Rectangle [] rects)
+                {
+                        if (rects == null)
+                                return;
+                        
+                        foreach (Rectangle rc in rects) 
+                                FillRectangle (ConvertBrush (brush), rc);
+                }
+
+                [MonoTODO]
+                void IGraphics.FillRectangles (System.Drawing.Brush brush, RectangleF [] rects)
+                {
+                        if (rects == null)
+                                return;
+                        
+                        foreach (RectangleF rc in rects) 
+                                FillRectangle (ConvertBrush (brush), rc);
+                }
+
+                [MonoTODO]
+                void IGraphics.FillRegion (System.Drawing.Brush brush, System.Drawing.Region region)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.Flush ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.Flush (FlushIntention intention)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public static Graphics FromHdc (IntPtr hdc)
+                {
+                        Graphics result = new Graphics (hdc);
+                        result.type = GraphicsType.FromHDC;
+                        return result;
+                }
+
+                [MonoTODO]
+                public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public static Graphics FromHdcInternal (IntPtr hdc)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public static Graphics FromHwnd (IntPtr hwnd)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public static Graphics FromHwndInternal (IntPtr hwnd)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                // TODO
+                [MonoTODO]
+                public static Graphics FromImage (System.Drawing.Image image)
+                {
+                        System.Drawing.Cairo.Image cairo_image = ConvertImage (image);
+                        IntPtr native = Cairo.cairo_create ();
+                        Graphics result = new Graphics (native);
+
+                        Cairo.cairo_set_target_image (native, 
+                                Gdk.Pixbuf.GetPixels (cairo_image.state),
+                                cairo_image.cairo_format,
+                                ((IImage) cairo_image).Width, ((IImage) cairo_image).Height,
+                                Gdk.Pixbuf.GetRowstride (cairo_image.state));
+				
+                        cairo_image.selected_into_graphics = result;
+                        result.initialized_from_image = cairo_image;
+                        result.type = GraphicsType.FromImage;
+                        return result;
+                }
+
+                [MonoTODO]
+                public static IntPtr GetHalftonePalette ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public IntPtr GetHdc ()
+                {
+                        return state;
+                }
+
+                [MonoTODO]
+                public Color GetNearestColor (Color color)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.IntersectClip (System.Drawing.Region region)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.IntersectClip (RectangleF rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.IntersectClip (Rectangle rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                public bool IsVisible (Point point)
+                {
+                        return IsVisible (point.X, point.Y);
+                }
+
+                public bool IsVisible (RectangleF rect)
+                {
+                        return IsVisible (rect.X, rect.Y, rect.Width, rect.Height);
+                }
+
+                public bool IsVisible (PointF point)
+                {
+                        return IsVisible (point.X, point.Y);
+                }
+
+                public bool IsVisible (Rectangle rect)
+                {
+                        return IsVisible (rect.X, rect.Y, rect.Width, rect.Height);
+                }
+                
+                [MonoTODO]
+                public bool IsVisible (float x, float y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public bool IsVisible (int x, int y)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public bool IsVisible (float x, float y, float width, float height)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public bool IsVisible (int x, int y, int width, int height)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public System.Drawing.Region [] MeasureCharacterRanges (string text, System.Drawing.Font font, RectangleF layoutRect, StringFormat stringFormat)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font, SizeF layoutArea)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font, int width)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font, SizeF layoutArea, StringFormat stringFormat)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font, int width, StringFormat format)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font, PointF origin, StringFormat stringFormat)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public SizeF MeasureString (string text, System.Drawing.Font font, SizeF layoutArea, StringFormat stringFormat, ref int charactersFitted, ref int linesFilled)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.MultiplyTransform (Matrix matrix)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.MultiplyTransform (Matrix matrix, MatrixOrder order)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                internal void ReleaseHdc (IntPtr hdc)
+                {
+                }
+
+                [MonoTODO]
+                void IGraphics.ReleaseHdc (IntPtr hdc)
+                {
+                }
+
+                [MonoTODO]
+                void IGraphics.ReleaseHdcInternal (IntPtr hdc)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.ResetClip ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.ResetTransform ()
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.Restore (GraphicsState gstate)
+                {
+                        Cairo.cairo_restore (state);
+                }
+
+                void IGraphics.RotateTransform (float angle)
+                {
+                        double rad = angle * Math.PI / 180.0;				
+                        Cairo.cairo_rotate (state, rad);
+                }
+
+                [MonoTODO]
+                void IGraphics.RotateTransform (float angle, MatrixOrder order)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                public GraphicsState Save ()
+                {
+                        Cairo.cairo_save (state);
+                        return new GraphicsState ();
+                }
+
+                [MonoTODO]
+                void IGraphics.ScaleTransform (float sx, float sy)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.ScaleTransform (float sx, float sy, MatrixOrder order)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (RectangleF rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (GraphicsPath path)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (Rectangle rect)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (System.Drawing.Graphics g)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (System.Drawing.Graphics g, CombineMode combineMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (Rectangle rect, CombineMode combineMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (RectangleF rect, CombineMode combineMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (System.Drawing.Region region, CombineMode combineMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.SetClip (GraphicsPath path, CombineMode combineMode)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.TranslateClip (int dx, int dy)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.TranslateClip (float dx, float dy)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                [MonoTODO]
+                void IGraphics.TranslateTransform (float dx, float dy)
+                {
+                        Cairo.cairo_translate (state, (double) dx, (double) dy);
+                }
+
+                [MonoTODO]
+                void IGraphics.TranslateTransform (float dx, float dy, MatrixOrder order)
+                {
+                        throw new NotImplementedException ();
+                }
+
+                System.Drawing.Region System.Drawing.IGraphics.Clip {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                //throw new NotImplementedException ();
+                        }
+                }
+
+                RectangleF IGraphics.ClipBounds {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                CompositingMode IGraphics.CompositingMode {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                throw new NotImplementedException ();
+                        }
+
+                }
+                CompositingQuality IGraphics.CompositingQuality {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                float IGraphics.DpiX {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                float IGraphics.DpiY {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                InterpolationMode IGraphics.InterpolationMode {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                bool IGraphics.IsClipEmpty {
+                        get  {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                bool IGraphics.IsVisibleClipEmpty {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                float IGraphics.PageScale {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                GraphicsUnit IGraphics.PageUnit {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                PixelOffsetMode IGraphics.PixelOffsetMode {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                Point IGraphics.RenderingOrigin {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                SmoothingMode IGraphics.SmoothingMode {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                int IGraphics.TextContrast {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                TextRenderingHint IGraphics.TextRenderingHint {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                Matrix IGraphics.Transform {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+
+                        set {
+                                throw new NotImplementedException ();
+                        }
+                }
+
+                RectangleF IGraphics.VisibleClipBounds {
+                        get {
+                                throw new NotImplementedException ();
+                        }
+                }
+        }
+}
+

+ 279 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/Image.cs

@@ -0,0 +1,279 @@
+//
+// System.Drawing.Image.cs
+//
+// (C) 2002/3 Ximian, Inc.  http://www.ximian.com
+// Authors:
+//   Christian Meyer <[email protected]>
+//   Jason Perkins <[email protected]>
+//   Dennis Hayes <[email protected]>
+//   Alexandre Pigolkine <[email protected]>
+
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Serialization;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Cairo {
+	//[Serializable]
+	//[ComVisible(true)]
+
+	internal abstract class Image : MarshalByRefObject, IImage /*, ICloneable, ISerializable */
+	{
+
+		internal IntPtr state;
+		internal Cairo.Format cairo_format;
+		internal System.Drawing.Cairo.Graphics selected_into_graphics = null;
+		internal Size size;
+		internal PixelFormat pixelFormat;
+		protected ImageFormat imageFormat;
+			
+		// constructor
+		public Image () {}
+
+		[MonoTODO]
+		public virtual object Clone()
+		{
+			throw new NotImplementedException ();
+		}
+    
+		// public methods
+		// static
+		public static Image FromFile (string filename)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+	
+		public static Image FromFile (string filename, bool useEmbeddedColorManagement)
+		{
+				
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+	
+		public static Bitmap FromHbitmap (IntPtr hbitmap)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+
+		public static Bitmap FromHbitmap (IntPtr hbitmap, IntPtr hpalette)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+		
+		[MonoTODO]
+		public static Image FromStream (Stream stream)
+		{
+			throw new NotImplementedException ();
+		}
+	
+		[MonoTODO]
+		public static Image FromStream (Stream stream, bool useIcm)
+		{
+			throw new NotImplementedException ();
+		}
+	
+		public static int GetPixelFormatSize (PixelFormat pixfmt)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+		
+		public static bool IsAlphaPixelFormat (PixelFormat pixfmt)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+			
+		public static bool IsCanonicalPixelFormat (PixelFormat pixfmt)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+	
+		public static bool IsExtendedPixelFormat (PixelFormat pixfmt)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+
+		// non-static
+		RectangleF IImage.GetBounds (ref GraphicsUnit pageUnit)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+	
+		[MonoTODO]
+		int IImage.GetFrameCount (FrameDimension dimension)
+		{
+			throw new NotImplementedException ();
+		}
+		
+		[MonoTODO]
+		PropertyItem IImage.GetPropertyItem (int propid)
+		{
+			throw new NotImplementedException();
+		}
+
+		void IImage.RemovePropertyItem (int propid)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+	
+		void IImage.RotateFlip (RotateFlipType rotateFlipType)
+		{
+			// Fixme: implement me
+			throw new NotImplementedException ();
+		}
+
+		protected InternalImageInfo sourceImageInfo = null;
+		unsafe InternalImageInfo IImage.ConvertToInternalImageInfo ()
+		{
+
+			if (sourceImageInfo == null) {
+				sourceImageInfo = new InternalImageInfo();
+				sourceImageInfo.Size = size;
+				sourceImageInfo.RawFormat = imageFormat;
+				sourceImageInfo.PixelFormat = PixelFormat.Format32bppArgb;
+				sourceImageInfo.Stride = Gdk.Pixbuf.GetRowstride (state);
+				sourceImageInfo.RawImageBytes = new byte[sourceImageInfo.Stride * size.Height];
+				IntPtr memptr = Gdk.Pixbuf.GetPixels (state);
+				Marshal.Copy( memptr, sourceImageInfo.RawImageBytes, 0, sourceImageInfo.RawImageBytes.Length);
+				sourceImageInfo.ChangePixelFormat (pixelFormat);
+			}
+			return sourceImageInfo;
+		}
+
+		void IImage.Save (string filename)
+		{
+			throw new NotImplementedException ();
+		}
+	
+		[MonoTODO]
+		void IImage.Save(Stream stream, ImageFormat format)
+		{
+			throw new NotImplementedException ();
+		}
+		
+		[MonoTODO]
+		void IImage.Save (string filename, ImageFormat format)
+		{
+			throw new NotImplementedException ();
+		}
+		
+		[MonoTODO]
+		int IImage.SelectActiveFrame (FrameDimension dimension, int frameIndex)
+		{
+			throw new NotImplementedException();
+		}
+	
+		[MonoTODO]
+		void IImage.SetPropertyItem (PropertyItem item)
+		{
+			throw new NotImplementedException();
+		}
+		// destructor
+		~Image() {}
+
+		// properties
+		int IImage.Flags {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		Guid [] IImage.FrameDimensionsList {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		int IImage.Height {
+			get {
+				return size.Height;
+			}
+		}
+	
+		float IImage.HorizontalResolution {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		ColorPalette IImage.Palette {
+			get {
+				throw new NotImplementedException ();
+			}
+			set {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		SizeF IImage.PhysicalDimension {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		PixelFormat IImage.PixelFormat {
+			get {
+				return pixelFormat;
+			}
+		}
+	
+		int [] IImage.PropertyIdList {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		[MonoTODO]
+		PropertyItem [] IImage.PropertyItems {
+			get {
+				throw new NotImplementedException();
+			}
+		}
+
+		[MonoTODO]
+		ImageFormat IImage.RawFormat {
+			get {
+				return imageFormat;
+			}
+		}
+
+		Size IImage.Size {
+			get {
+				return size;
+			}
+		}
+	
+		float IImage.VerticalResolution {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
+	
+		int IImage.Width {
+			get {
+				return size.Width;
+			}
+		}
+
+		[MonoTODO]
+		public void Dispose ()
+		{
+		}
+
+		[MonoTODO]
+		protected virtual void Dispose (bool disposing)
+		{
+			throw new NotImplementedException();
+		}
+	}
+}

+ 141 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/Pen.cs

@@ -0,0 +1,141 @@
+//
+// System.Drawing.Pen.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//   Alexandre Pigolkine([email protected])
+// 
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+
+namespace System.Drawing.Cairo {
+
+        internal class PenFactory : IPenFactory
+        {
+                public IPen Pen (System.Drawing.Brush brush, float width)
+                {
+                        return new Pen (brush, width);
+                }
+
+                public IPen Pen (System.Drawing.Color color, float width)
+                {
+                        return new Pen (color, width);
+                }
+        }
+
+        public sealed class Pen : MarshalByRefObject, IPen
+        {
+                System.Drawing.Brush brush = null;
+                Color color = Color.Black;
+                float width = 1.0F;
+
+                void CommonInit()
+                {
+                        //nativeObject_ = Xr.MonoGI_CreatePen((double)color.R, (double)color.G, (double)color.B,(double)width);
+                }
+					
+                public Pen (System.Drawing.Brush brush)
+                {
+                        this.brush = brush;
+                        // FIXME: get color from brush
+                        CommonInit();
+                }
+
+                public Pen (Color color)
+                {
+                        this.color = color;
+                        CommonInit();
+                }
+
+                public Pen (System.Drawing.Brush brush, float width)
+                {
+                        this.width = width;
+                        this.brush = brush;
+                        // FIXME: get color from brush
+                        CommonInit();
+                }
+
+                public Pen (Color color, float width)
+                {
+                        this.width = width;
+                        this.color = color;
+                        CommonInit();
+                }
+
+                internal void initialize (IntPtr cs)
+                {
+                        Cairo.cairo_set_rgb_color (cs,
+                                        (double) color.R,
+                                        (double) color.G,
+                                        (double) color.B);
+
+                        Cairo.cairo_set_line_width (cs, (double) width);
+                }
+			
+                //
+                // Properties
+                //
+                //		public PenAlignment Alignment {
+                //			get {
+                //				return alignment;
+                //			}
+                //
+                //			set {
+                //				alignment = value;
+                //			}
+                //		}
+
+                System.Drawing.Brush IPen.Brush {
+                        get {
+                                return brush;
+                        }
+
+                        set {
+                                brush = value;
+                        }
+                }
+
+                Color IPen.Color {
+                        get {
+                                return color;
+                        }
+
+                        set {
+                                color = value;
+                        }
+                }
+
+                float IPen.Width {
+                        get {
+                                return width;
+                        }
+
+                        set {
+                                width = value;
+                        }
+                }
+
+                void IDisposable.Dispose ()
+                {
+                        Dispose (true);
+                        System.GC.SuppressFinalize (this);
+                }
+
+                void Dispose (bool disposing)
+                {
+                        if( disposing) 
+                        {
+                                //Xr.MonoGI_DestroyPen(nativeObject_);
+                        }
+                }
+
+                ~Pen ()
+                {
+                        Dispose (false);
+                }
+        }
+}
+

+ 57 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/SolidBrush.cs

@@ -0,0 +1,57 @@
+ //
+// System.Drawing.SolidBrush.cs
+//
+// Author:
+//   Dennis Hayes ([email protected])
+//   Alexandre Pigolkine([email protected])
+//
+// (C) 2002 Ximian, Inc
+//
+using System;
+
+namespace System.Drawing.Cairo {
+
+        internal class SolidBrushFactory : ISolidBrushFactory
+        {
+                ISolidBrush ISolidBrushFactory.SolidBrush (Color color)
+                {
+                        return new SolidBrush(color);
+                }
+        }
+
+        internal class SolidBrush : Brush, ISolidBrush 
+        {
+		
+                Color color;
+
+                public SolidBrush (Color color)
+                {
+                        this.Color = color;
+                }
+
+                public Color Color {
+
+                        get { return color; }
+
+                        set { color = value; }
+                }
+		
+                public override object Clone ()
+                {
+                        return new SolidBrush (color);
+                }
+		
+                Color IBrush.TextColor 
+                {
+                        get { return Color; }
+                }
+			
+                internal void initialize (IntPtr cr)
+                {
+                        Cairo.cairo_set_rgb_color (cr,
+                                        (double) color.R,
+                                        (double) color.G,
+                                        (double) color.B);
+                }
+        }
+}

+ 425 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/cairo.cs

@@ -0,0 +1,425 @@
+//
+// Cairo.cs
+//
+// Author: Duncan Mak ([email protected])
+//
+// (C) Ximian, Inc. 2003
+//
+// This is a simplistic binding of the Cairo API to C#. All functions
+// in cairo.h are transcribed into their C# equivelants and all
+// enumerations are also listed here.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing.Cairo {
+
+	public class Cairo
+        {
+                const string CairoImp = "cairo";
+                //
+                // Manipulating state objects
+                //
+		[DllImport (CairoImp)]
+		public static extern IntPtr cairo_create ();
+
+		[DllImport (CairoImp)]
+		public static extern IntPtr cairo_destroy (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_save (IntPtr cr);                
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_restore (IntPtr cr);
+
+                //
+                // Modify state
+                //
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_target_surface (IntPtr cr, IntPtr surface);
+                                
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_target_image (
+                        IntPtr cr, IntPtr data, Cairo.Format format, int width, int height, int stride);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_target_drawble (IntPtr cr, IntPtr dpy, ulong drawable);
+                
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op);
+
+       		[DllImport (CairoImp)]
+		public static extern void cairo_set_rgb_color (IntPtr cr, double red, double green, double blue);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_alpha (IntPtr cr, double alpha);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_pattern (IntPtr cr, IntPtr pattern);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_tolerence (IntPtr cr, double tolerance);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_line_width (IntPtr cr, double width);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_line_cap (IntPtr cr, Cairo.LineCap line_cap);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_line_join (IntPtr cr, Cairo.LineJoin line_join);
+
+       		[DllImport (CairoImp)]
+		public static extern void cairo_set_dash (IntPtr cr, double [] dashes, int ndash, double offset);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_set_miter_limit (IntPtr cr, double limit);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_translate (IntPtr cr, double tx, double ty);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_scale (IntPtr cr, double sx, double sy);
+
+                [DllImport (CairoImp)]                
+                public static extern void cairo_rotate (IntPtr cr, double angle);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_concat_matrix (IntPtr cr, IntPtr matrix);                
+                
+                [DllImport (CairoImp)]
+                public static extern void cairo_set_matrix (IntPtr cr, IntPtr matrix);
+                
+                [DllImport (CairoImp)]
+                public static extern void cairo_default_matrix (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_identity_matrix (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_transform_point (IntPtr cr, ref double x, ref double y);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_transform_distance (IntPtr cr, ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_inverse_transform_point (IntPtr cr, ref double x, ref double y);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_inverse_transform_distance (IntPtr cr, ref double dx, ref double dy);
+
+                //
+                // Path creation
+                //
+		[DllImport (CairoImp)]
+		public static extern void cairo_new_path (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_move_to (IntPtr cr, double x, double y);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_line_to (IntPtr cr, double x, double y);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_curve_to (
+                        IntPtr cr, double x1, double y1, double x2, double y2, double x3, double y3);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rel_move_to (IntPtr cr, double dx, double dy);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rel_line_to (IntPtr cr, double dx, double dy);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rel_curve_to (
+                        IntPtr cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_rectangle (IntPtr cr, double x, double y, double width, double height);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_close_path (IntPtr cr);
+
+                //
+                // Painting
+                //
+                [DllImport (CairoImp)]
+                public static extern void cairo_stroke (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_fill (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_clip (IntPtr cr);
+
+                //
+                // Font / Text
+                //
+                [DllImport (CairoImp)]
+                public static extern void cairo_select_font (IntPtr cr, string key);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_scale_font (IntPtr cr, double scale);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_transform_font (
+                        IntPtr cr, double a, double b, double c, double d);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_text_extents (
+                        IntPtr cr, string utf8,
+                        ref double x, ref double y,
+                        ref double width, ref double height,
+                        ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_show_text (IntPtr cr, string utf8);
+
+                //
+                // Image
+                //                
+                [DllImport (CairoImp)]
+                public static extern void cairo_show_surface (IntPtr cr, IntPtr surface, int width, int height);
+
+                //
+                // query
+                //                                
+                [DllImport (CairoImp)]
+		public static extern Cairo.Operator cairo_get_operator (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_get_rgb_color (
+                        IntPtr cr, out double red, out double green, out double blue);
+
+                [DllImport (CairoImp)]
+                public static extern double cairo_get_alpha (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern double cairo_get_tolerence (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern void cairo_get_current_point (
+                        IntPtr cr, out double x, out double y);
+
+		[DllImport (CairoImp)]
+		public static extern Cairo.FillRule cairo_get_fill_rule (IntPtr cr);
+
+                [DllImport (CairoImp)]
+		public static extern double cairo_get_line_width (IntPtr cr);
+
+                [DllImport (CairoImp)]
+		public static extern LineCap cairo_get_line_cap (IntPtr cr);
+
+       		[DllImport (CairoImp)]
+		public static extern LineJoin cairo_get_line_join (IntPtr cr);
+
+		[DllImport (CairoImp)]
+		public static extern double cairo_get_miter_limit (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_get_matrix (
+                        IntPtr cr,
+                        out double a, out double b,
+                        out double c, out double d,
+                        out double tx, out double ty);
+
+                [DllImport (CairoImp)]
+                public static extern void cairo_get_target_surface (IntPtr cr);
+
+                //
+                // Error status queries
+                //
+                [DllImport (CairoImp)]
+                public static extern Cairo.Status cairo_get_status (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                public static extern string cairo_get_status_string (IntPtr cr);
+
+                //
+                // Surface Manipulation
+                //
+                
+                [DllImport (CairoImp)]
+                public static extern IntPtr cairo_surface_create_for_drawable (
+                        IntPtr display, ulong drawable, IntPtr visual,
+                        Cairo.Format format, ulong colormap);
+
+                [DllImport (CairoImp)]                
+                public static extern IntPtr cairo_surface_create_for_image (
+                        string data, Cairo.Format format, int width, int height, int stride);
+
+                [DllImport (CairoImp)]
+                public static extern IntPtr cairo_surface_create_similar (
+                        IntPtr surface, Cairo.Format format, int width, int height);
+
+                [DllImport (CairoImp)]                
+                public static extern IntPtr cairo_surface_create_similar_solid (
+                        IntPtr surface, Cairo.Format format,
+                        int width, int height, double red, double green, double blue, double alpha);
+
+                [DllImport (CairoImp)]                
+                public static extern void cairo_surface_destroy (IntPtr surface);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_put_image (
+                        IntPtr surface, string data, int width, int height, int stride);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_set_repeat (
+                        IntPtr surface, int repeat);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_set_matrix (
+                        IntPtr surface, IntPtr matrix);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_get_matrix (
+                        IntPtr surface, ref IntPtr matrix);
+
+                [DllImport (CairoImp)]                
+                public static extern Cairo.Status cairo_surface_set_filter (
+                        IntPtr surface, Cairo.Filter filter);
+
+                //
+                // Matrix
+                //
+
+                [DllImport (CairoImp)]                
+                public static extern IntPtr cairo_matrix_create ();
+
+                [DllImport (CairoImp)]                
+                public static extern void cairo_matrix_destroy (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_copy (
+                        IntPtr matrix, out IntPtr other);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_set_identity (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_set_affine (
+                        IntPtr matrix,
+                        double a, double b, double c, double d, double tx, double ty);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_get_affine (
+                        IntPtr matrix,
+                        out double a, out double b, out double c, out double d, out double tx, out double ty);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_translate (
+                        IntPtr matrix, double tx, double ty);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_scale (
+                        IntPtr matrix, double sx, double sy);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_rotate (
+                        IntPtr matrix, double radians);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_invert (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_multiply (
+                        out IntPtr result, IntPtr a, IntPtr b);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_transform_distance (
+                        IntPtr matrix, ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]                                
+                public static extern Cairo.Status cairo_matrix_transform_point (
+                        IntPtr matrix, ref double x, ref double y);
+        }
+
+        //
+        // Enumerations
+        //
+        public enum Format {
+                ARGB32 = 0,
+                RGB24 = 1,
+                A8 = 2,
+                A1 = 4
+        }
+
+        public enum Operator {
+                Clear = 0,
+                Src = 1,
+                Dst = 2,
+                Over = 3,
+                OverReverse = 4,
+                In = 5,
+                InReverse = 6,
+                Out = 7,
+                OutReverse = 8,
+                Atop = 9,
+                AtopReverse = 10,
+                Xor = 11,
+                Add = 12,
+                Saturate = 13,
+                
+                DisjointClear = 16,
+                DisjointSrc = 17,
+                DisjointDst = 18,
+                DisjointOver = 19,
+                DisjointOverReverse = 20,
+                DisjointIn = 21,
+                DisjointInReverse = 22,
+                DisjointOut = 23,
+                DisjointOutReverse = 24,
+                DisjointAtop = 25,
+                DisjointAtopReverse = 26,
+                DisjointXor = 27,
+
+                ConjointClear = 32,
+                ConjointSrc = 33,
+                ConjointDst = 34,
+                ConjointOver = 35,
+                ConjointOverReverse = 36,
+                ConjointIn = 37,
+                ConjointInReverse = 38,
+                ConjointOut = 39,
+                ConjointOutReverse = 40,
+                ConjointAtop = 41,
+                ConjointAtopReverse = 42,
+                ConjointXor = 43
+        }
+
+        public enum FillRule {
+                Winding,
+                EvenOdd
+        }
+
+        public enum LineCap {
+                Butt, Round, Square
+        }
+
+        public enum LineJoin {
+                Miter, Round, Bevel
+        }
+
+        public enum Status {
+                Success = 0,
+                NoMemory,
+                InvalidRestore,
+                InvalidPopGroup,
+                NoCurrentPoint,
+                InvalidMatrix
+        }
+
+        public enum Filter {
+                Fast,
+                Good,
+                Best,
+                Nearest,
+                Bilinear
+        }
+}

+ 34 - 0
mcs/class/System.Drawing/System.Drawing/impl/cairo/gdk-helpers.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace Gdk {
+
+        internal class Pixbuf
+        {
+                const string libgdk_pixbuf = "libgdk_pixbuf-2.0.0.dll";
+                
+		[DllImport (libgdk_pixbuf, EntryPoint="gdk_pixbuf_new")]
+		internal static extern IntPtr New (
+                        int colorspace, bool has_alpha, int bits_per_sample,
+                        int width, int height);
+
+		[DllImport(libgdk_pixbuf, EntryPoint = "gdk_pixbuf_new_from_data")]
+		internal static extern IntPtr NewFromData (
+                        IntPtr data, Gdk.Colorspace colorspace, bool has_alpha, int bits_per_sample,
+                        int width, int height, int rowstride,
+                        IntPtr destroy_fn, IntPtr destroy_fn_data);
+
+		[DllImport(libgdk_pixbuf, EntryPoint = "gdk_pixbuf_finalize")]
+                internal static extern void Finalize (IntPtr pixbuf);
+
+                [DllImport (libgdk_pixbuf, EntryPoint = "gdk_pixbuf_get_pixels")]
+                internal static extern IntPtr GetPixels (IntPtr pixbuf);
+
+                [DllImport (libgdk_pixbuf, EntryPoint = "gdk_pixbuf_get_rowstride")]
+                internal static extern int GetRowstride (IntPtr pixbuf);
+        }
+
+        internal enum Colorspace {
+                Rgb = 0
+        }
+}