12.4. Drawing Images on the Web
The process of drawing images on the Web is slightly different from that of drawing images on Windows Forms. In Windows Forms we create a Bitmap object and call the Graphics.DrawImage method. Drawing on the Web requires a Graphics object. The Bitmap.Save method takes care of the rest, as discussed earlier.
To test this, let’s create a Web application using Visual Studio .NET and add the code given in Listing 12.5 on the page-load event. This code views an image on the browser. First we create a Bitmap object from an image, then we create a Graphics object from the image, and then we call the Save method of Bitmap.
Listing 12.5. Drawing images on the Web
// Create a Bitmap object from a file Bitmap curBitmap = ... |
Get Graphics Programming with GDI+ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.