Login | Register   
LinkedIn
Google+
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+ : Page 2

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


advertisement
The Graphics Object
The Graphics object is contained in the PaintEventArgs parameter (which is the second parameter of the event handler ImageProcessorUI_Paint), and it summarizes the GDI+ drawing surface. Use it to draw images to the screen. The Graphics object has two important properties, both of which are enumerations from the System.Drawing.Drawing2D namespace:
  • SmoothingMode: This property specifies whether anti-aliasing will be applied when drawing images. Anti-aliasing is used to smooth out distortion in images.
  • InterpolationMode: This property is used when you stretch or shrink images. With shrinking, you are mapping several pixels to a single pixel. In stretching, you are mapping a single pixel to several pixels. .NET provides several algorithms to achieve this, and you specify the algorithm you wish to use with the InterpolationMode.

Reading MetaData Information from an Image
The sample application reads metadata information from digital images, and displays the focal length, aperture, shutter speed, ISO speed, and date the image was recorded. In .NET, an image is represented by the class System.Drawing.Bitmap (derived from the System.Drawing.Image class). PropertyItem in the System.Drawing namespace represents a particular piece of metadata. There are two methods on System.Drawing.Bitmap that you can use to write or read metadata from images:

  • setPropertyItem: Use this method to write metadata information into images.
  • getPropertyItem: Use this method to retrieve metadata stored in image files.
All the pieces of metadata in an image are available in the image's PropertyItems property.

The Id property of a PropertyItem object is an integer that uniquely identifies the piece of metadata a PropertyItem represents. However, metadata pieces are identified in the real world using hexadecimal string, so you need to convert this integer to an hexadecimal string using some code like this (mg is an instance of a System.Drawing.Image class)



PropertyItem p = mg.PropertyItems[i]; string imageIdentifier = p.Id.ToString("X");

MSDN contains some well-known tags for the EXIF image format. The sample application contains additional tags that you can use. www.exif.org also contains an exhaustive list of all the tags a digital image can possibly contain.

Metadata comes in various data types: bytes, signed/unsigned rational, signed/unsigned, long, etc. This sample application contains many of examples for decoding some of these data types.



Comment and Contribute

 

 

 

 

 


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

 

 

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