Handling Dynamic Images in ASP.NET 3.5 AJAX Applications
(Page 1 of 5 )
In the examples in the first part of this series, we discussed ways to make static image data persist in the server side files or databases. Nevertheless, in many other web applications, such as those on finance and economics sites, the images or charts are usually generated on the server side dynamically, and then sent back to the browser side in binary data via the HttpResponse output stream. This article, the conclusion to this two-part series, will show you how.
GDI+ comes to the rescue
How can you create and manipulate these kinds of dynamic server side images? Traditionally, most solutions fall back on third party libraries or other applications-provided image engines (such as Microsoft Office). Nowadays, things have changed drastically; GDI+, the next generation of image engine under .NET environments, offers a solution. ASP.NET applications can use GDI+ as the back-end image engine to generate any required static or dynamic images or charts on the fly.
As you may have realized from reading my previous articles, GDI+ brings forward a fully object-oriented programming model instead of the device context and object handle to greatly simplify the image handling in .NET environments. The most important concept introduced in GDI+ is Graphics, which plays the role of a central controller when rendering. The other important concepts are Image class, Bitmap class, and many other new object models.
Moreover, it is worth noticing that, to provide images dynamically, you must utilize a custom HTTP handler. The modes for the handler to obtain the image bits should rest on their inner implementation. There are generally three ways to do this: store the image bits in a database, ASP.NET Cache, or generate the image data dynamically.
Next: Constructing an ASP.NET AJAX Styled Message Board Sample >>
More ASP.NET Articles
More By Xianzhong Zhu