Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Discover Enhanced Image Manipulation with GDI+

Is image processing in unmanaged C++ a thing of the past? See how GDI+ measures up by using this sample image manipulation tool.


advertisement
s there any reason to do image processing in unmanaged code anymore? GDI+'s managed classes may just be good enough to give the unmanaged approach (mainly in unmanaged C++) a run for its money. GDI+ classes allow you to read the metadata information stored in images recorded by a digital camera&151;and then resize those images while ensuring image quality. The ImageAttributes and ColorMatrix classes help with color adjustment and the image codecs class specifies the colour depth and quality of the jpeg images.

In this article, you'll learn about GDI+'s enhanced image manipluation capabilities by building a multithreaded, image-resizing tool. Decide for yourself whether it's better!

Figure 1. The sample application, showing various extracted metadata. This image was recorded using a Canon EOS D60.



The Sample Application
The application, shown in Figure 1, was written using C#. Scale the image uniformly by specifying a percentage, or specify the height and width for the new image. You can also specify the number of threads you want to use to process the image. Simply select the image you want to resize and click the resize button (or select resize on the short cut menu).

When you select File—>Open, a common dialog screen allows you to choose the images you wish to modify. Various details about each of the selected images are extracted and populated in a data grid. Details such as focal length, aperture, and ISO speed are extracted from the metadata contained in the image. Right-click anywhere on the displayed image and you'll see the shortcut menu (Figure 2). Use the short cut menu to carry out various image transformations.

Figure 2. The image resizing tool performs various colour transformations.

Drawing Images in .NET
To draw images on the form, you need to let the .NET Framework know of your intention to handle the paint event:

this.Paint+=new PaintEventHandler(this.ImageProcessorUI_Paint);

You also need to provide an event handler—in this instance, ImageProcessorUI_Paint. Make sure its signature matches the PaintEventHandler delegate:

void ImageProcessorUI_Paint(object sender, PaintEventArgs e)



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap