Developing GDI+ Web Applications

In previous chapters we covered almost every aspect of drawing using Windows Forms. This chapter will introduce you to drawing on the Web and show how GDI+ can be used to write powerful graphics Web applications. From a programmer's perspective, GDI+ treats both Windows and Web applications in the same way.

This chapter covers the following topics:

If we want to draw a rectangle on the Web, we create a Graphics object and call its DrawRectangle method. However, getting a Graphics object for a Web page is different from getting one for a Windows Form, as we will discuss in greater detail later.

Another restriction in Web applications is the fact that a browser can display only images. If we wanted to draw a rectangle on a Web page, the rectangle would first have to be drawn and converted into an image and then sent to the browser for display.

To draw graphics shapes in a Windows Forms application, we simply call the draw or fill method, and GDI+ draws the shape on the form, as Figure 12.1 shows.

Figure 12.1. Drawing in Windows Forms

Drawing in Web Forms involves one extra step. When you call a draw or fill method, GDI+ doesn't communicate directly with the Web Forms. Instead, it allows us to save a graphics shape as an image. Later we send the image to the browser for display. This process is shown in Figure 12.2.

Figure 12.2. Drawing in Web Forms

After completing this chapter, you will be amazed by the power and flexibility of GDI+ and ASP.NET.

Категории