[Mono-devel-list] to draw or not to draw

Miguel de Icaza miguel at ximian.com
Mon Feb 23 11:24:33 EST 2004


Hello,

> SWF is not stable and is broken under Mono.
> again you've got to wait got for a couple of month to have a working SWF 
> under Mono.
> That's said SWF throught wine is not really robust,  gtk# is more robust 
> but gdk is very weak for drawing.
>
> SD is usable but you've to render to a bitmap.
> 
> So it is impossible to write a real world application with complicated 
> graphics under Mono. for the moment.

As you well point out, Windows.Forms is currently broken, but we have
full time people working on solving this problem.  Including making the
Wine edition robust.  The downside?  You will have to wait a few months
for it.

System.Drawing also has various developers working on it, so the quality
and robustness of this is rapidly maturing.

> It 's seems that few people are interested in drawing in the mono galaxy. 
> I don't understand why Novell/Ximian/Suse don't hire a team of developpers 
> to work on wine, gdiplus, SD, SWF.

That is not true;  We have three full time developers working on that
problem, and one part time developer.  It just takes time to get things
right.

> That's a strategic area for me. not for miguel. :-(

Wrong again, it is very important to have good drawing.

> Perhaps you should use gkt# and write a decent layer on the top of gdk# to 
> handle drawing in the spirit of SD.

Let me offer you a few more solutions:

	* I posted a patch to Gtk-sharp-list that added integration with
	  Cairo to draw on Windows and Pixmaps (used on the Expose event).

	  Cairo is a fairly high-level rendering API, similar to Postscript
	  and System.Drawing and offers a composition model, full with anti-aliased
	  and alpha rendering.
	  

	  The patch was not accepted since Cairo does not work on Windows
	  yet, so Mike did not want to add a dependency on it just yet, 
	  but the good news is that you can use the principle from the patch
	  *today* to use Cairo for rendering (you just need to write 
	  a small helper routine that does what my patch did).

	  See: gtk-sharp/sample/CairoSample.cs

	* You can try System.Drawing from CVS which is more advanced and I 
	  could cook you a patch to use System.Drawing in Gtk#

For now, to use Cairo on Gtk#, you can use this helper routine:

Cairo.Graphics GetGraphics (Gdk.Window w, out int offx, out int offy)
{
       IntPtr real_drawable;
       Cairo.Graphics o = new Cairo.Graphics ();

       gdk_window_get_internal_paint_info (w.Handle, out real_drawable, out offset_x, out offset_y);
       IntPtr x11 = gdk_x11_drawable_get_xid (real_drawable);
       IntPtr display = gdk_x11_drawable_get_xdisplay (real_drawable);
       o.SetTargetDrawable (display, x11);

       return o;
}

Cairo.Graphics GetGraphics (Gdk.Window w)
{
	int x, y;
	return GetGraphics (w, out x, out y);
}





More information about the Mono-devel-list mailing list