Simplified Image Processing in GDI+
(Page 1 of 6 )
With GDI+ coming into its own in the two-dimensional image processing field, image processing was drastically simplified. Those who have become accustomed to traditional GDI may feel a bit puzzled with the image handling introduced in GDI+. Once they grow accustomed to the differences, which should happen quickly, they will probably prefer GDI+. Keep reading to find out why, and to learn GDI+'s image processing methods through several examples. This article is the first of two parts.
Introduction
With GDI+, users of traditional GDI will notice that they can no longer find the troublesome DIB or DDB concepts, nor can they find data structures such as the BMP file header and the BMP-related palette which brought so much trouble to Windows GDI developers. In GDI+, there are almost no absolute limits between various picture files. A typical example is that in GDI+ you may find that you can use almost the same means to manipulate BMP files as you do with JPEG or PNG format files.
Digging deeper into GDI+, you will see that there are three main classes, i.e. Image, Bitmap, and Metafile, introduced to deal with common and typical image processing. The Bitmap class provides methods to load, save, and handle raster images, which to some degree expands the abilities of the Image class. In contrast, the Metafile class has enhanced the Image class by introducing additional methods to record and validate vector images.
There are many concepts as well as higher theories with images. However, we are not going to dwell much on these monotonous and bald doctrines. In this article, I will show you the richer and easier support available in GDI+ to process images through several samples.
Open and Render Images
There are mainly two classes introduced to manipulate and maintain image processing, i.e. Image and Bitmap. The Bitmap class derives from the base class Image. Here we are mainly interested in the Bitmap class.
There are 12 variations of constructor for the Bitmap class. As for rendering an image file, this is typically performed using the DrawImage methods of the Graphics class-there are 30 kinds of definitions for the DrawImage method. There are so many rich invocations for the DrawImage method that you can deal with an image in GDI+ with great ease and flexibility. For example, the functionalities, rotating, and inverting, interpolating with any special angle, that can not be directly accomplished using the API BitBlt() in GDI can now be easily achieved using the DrawImage method in GDI+.
Here we do not plan to list the dozens of variations of the DrawImage method, but summarize what you can do with it:
- You can use the DrawImage method to render many kinds of images at the specified locations as well as scaling them.
- You can utilize the point information in the screen to describe the location of an image using the DrawImage method to rotate it at any specified angle, which is quite different from what you can achieve using the coordination transformation in the drawing plane.
- If the ImageAttributes function is enabled in the DrawImage method, you can validate the color information of an image as well as specify the color-rendering channel.
Next: Meta File Support in GDI >>
More Windows Scripting Articles
More By Xianzhong Zhu