Interest in adding GD renderer for web?

Topics: Web Controls
Coordinator
Jun 19, 2007 at 9:32 AM
As you may or may not know, the System.Drawing namespace objects (Graphics, Bitmap, Point, Brush, etc.) should not be used on a web site. Of course, we're all doing it, since there are no easy alternatives - these are the only drawing tools we have in the .Net framework.

The reason for this that System.Drawing just wraps an underlying Win32 drawing library called GDI+. GDI+ rests on the age-old GDI32 - which was developed and completed before the HTTP protocol caught on, and thus is very client-oriented. It makes assumptions about the kind of environment it has, and it is only designed to scale up to one user's machine, not a huge server with thousands of users a day. It makes these assumptions because it expects anything that needs drawing on (monitor, printer, file, etc.) to be local, and in use by one person at a time - a reasonable assumption for a PC OS in 1994. In fact, Microsoft is aware of all this, and clearly states on the System.Drawing namespace documentation:

  • Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

In v2.0 of SharpMap, the rendering pipeline is redesigned. This gives us the opportunity to change the rendering technology used to produce the image. On the client side, this was done to support a WPF renderer. It is also possible to do this on the web.

The GD library is a mature, well-tested and widely deployed graphics generation library geared towards using on the web to create dynamic images. There is apparently a project which has developed C# bindings called GD-Sharp, which may be suitable to build a web-renderer from.

What I'd like to know is 1) is there interest in this and 2) is there anyone interested in doing it?
Developer
Jun 19, 2007 at 9:27 PM
Another option is AGG (see C# wrapper) which is in consideration for Mono version of Silverlight.

However, I think the main issue is not Web environment but hardware acceleration.
System.Drawing/GDI+, GD and AGG are software based rendering engines. WPF, Tao/OpenGL and DirectX are hardware accelerated and worth by far the effort (even in PPC platform, as you said in another post).

Best regards,
Ricardo Stuven.
Coordinator
Jun 19, 2007 at 9:49 PM
Edited Jun 19, 2007 at 9:57 PM
Actually, GDI+ is hardware accelerated - it's part of the driver model which Win95 developed for display technologies, and which WinNT 4.0 refactored the Win32 subsystem into kernel space to support. It's part of the reason why it's such a poor choice for servers - they often don't have the hardware needed for hardware accelerated drawing, and GDI+ is tightly coupled to the display driver. Oddly, it can be worse if it is accelerated, since the GPU doesn't handle multiple requests well (still, although DX10 opens the possibility). Finally, since the driver is a kernel-mode construct it opens the door to a machine-level vulnerability. You can see where GDI+ is a poor choice for web servers generating map images. For web maps, we want a pure software solution. For a Sliverlight app or PPC, however, since it is client side, we would want that acceleration.

Wow, AGG looks like a very good renderer - very high quality. I vaguely remember reading about this one years ago, and it has since dropped off my radar. Thanks for the tip!

I'm open to whatever, though. I'm mainly interested in how much interest there is in having an alternative for GDI+ on web servers... and if anyone wants to take this project on.