The ASP.NET team released a new generated image control on to Codeplex today. You can download the bits here and read a very simple explanation of the control here.
The concept is simple: a handler that takes in a few parameters will render out an image. The control does what you would expect by instantiating the appropriate objects out of System.Drawing and renders the image to the screen. This handler may or may not be called by a generated image control in your ASPX markup, making it easy to implement into your HTML.
Using this control you’ll be able to render simple text as well as complex geometries and even graphs and charts.
Finding Chinks in the Armor
My first thought was to see how the control deals with transparency. While you can set the background color to transparent, I had a hard time getting text to look good with a transparent background. In image editing packages you can set a "matte" color which will step between transparency and the color of the text to preserve anti aliasing.I wasn't able to find a way to set a matte color. NOTE: There is the all-too-likely chance though that I missed something, so if you can point me in the right direction on this, please leave a comment.
Where’s the Evil?
Purists will undoubtedly criticize the use of this control to simply render text. Some say that you should never use an image to render text. While there is an excellent point in this position I think it’s important not to go overboard. There is nothing stopping you from by-passing the generated image control and accessing the handler directly to render the image. Using this approach you can simply define a background image in your style sheet and still render the appropriate text in HTML. (You can find many examples of this technique here)
Score on Day One
All in all I think they did a good job of making a control that is easy to use. In the future I would like to know more about how the handler deals with caching, effects performance and if there are any associated gotchas… but hey they just released it today, right? :)
If you are looking for a package to handle charts and graphs you may want to check out the NetAdvantage WebChart... I'm just sayin' ;)