RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Using GDI+ in ASP.NET Web Applications, Part II

GDI+ is generally considered a Windows technology. However, some of the new GDI+ features make this technology an excellent choice for Web applications, enabling developers to generate images, graphs, diagrams, and much more on the fly.

ast issue's article, "Using GDI+ in ASP.NET Web Applications, Part 1", introduced basic concepts for generating images dynamically to use on Web pages. Keep in mind that the fundamental steps include: generation of in-memory Bitmap objects, drawing using the GDI+ API, and streaming the binary result back to the client (browser) using the ASP.NET OutputStream object.

In the last issue, I investigated GDI+ and how to use it for image manipulation in Web applications. This time around, I will look at the generation of brand new images using the same GDI+ technology and features.

The techniques demonstrated in this second article are very similar. The main difference lies in the in-memory Bitmap on which you will draw. Although in the previous article you started out with an existing image, in this article I'll show you how to draw on a completely blank image, generated from scratch.

A Text Example
To start out I'll show you how to generate text output.

One task that is generally tricky on Web pages (especially in a browser-neutral environment) is displaying drop caps (see Figure 1 for an example, and the sidebar called "Drop Caps" for more information). This is a very widely used technique in other publishing environments, but in HTML, there is no native way to produce them. For this reason, most Web sites that use drop caps generate (static) images for the utilized letters. Using GDI+ you can make this task straightforward and dynamic.

Thanks for your registration, follow us on our social networks to keep up-to-date