Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Modify Image Data
Implement image-manipulation code using the .NET Framework's GDI+ and System.Drawing classes.
by Randy Holloway

January 2003 Issue

Technology Toolbox: C#, ASP.NET

Most Web applications make use of digital photographs or other graphics, either to aid in development of the app's user interface or to convey image-related content in conjunction with text-formatted data. Many applications need only static image data, and you either reference the image files directly in the code or reference them dynamically based on data retrieved from a database or other data store you use to manage image-related data. However, in some cases, you might want to modify image data while the application is in use—for example, in Web-based photo albums and photo editors, where changing image data might be required functionality. With ASP.NET and GDI+—the Windows graphic-design interface—you can develop applications to manage and manipulate image data. GDI+ provides a rich API for graphical functions, including support for 2-D vector graphics, imaging, and typography. These graphical functions are exposed through a managed class interface in the .NET Framework. These rich graphics features enable you to develop code to perform image manipulations in your Web-based apps.

ADVERTISEMENT

To leverage these imaging functions, you need a basic understanding of GDI+ and the imaging functionality the .NET Framework supports. You should also be familiar with the key classes available in the System.Drawing and System.Drawing.Imaging namespaces that support the management and modification of image data; these include the Image, Graphics, and Bitmap classes. I'll discuss how you can use these classes to load and save image files, and examine their support for changing image content and file formats. I'll show you how to review code from an application that demonstrates the image-manipulation capabilities of the .NET Framework and GDI+ with ASP.NET. The sample app performs several types of image manipulations, including image cropping, image rotations, and changing an image's file format. I'll also discuss how you can apply these techniques in ASP.NET applications to render image data dynamically.

Extensive imaging support is available with GDI+ through the .NET Framework: native support for image file formats including JPEG, BMP, GIF, TIFF, and more; architectural support for extensibility to support new image formats; support for common imaging operations including adjustments for contrast, brightness, and blurring; and support for image transformations such as cropping, rotation, and flipping. You can take advantage of this functionality by implementing classes that the System.Drawing and System.Drawing.Imaging namespaces contain. The Image class supports numerous functions for dealing with image data. It also serves as the base class from which the Bitmap class is derived. The Bitmap class consists of the pixel data for an image as well as related attributes, and its instance of a Bitmap is the most common method for dealing with images defined by pixel data. The System.Drawing.Imaging namespace contains an ImageFormat class you can use to specify an image's format. The Image class uses an instance of this class as an input parameter for functions that support saving and converting the image data the object contains from one format to another.

Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home