Color Transformation in C# GDI+ Programming
(Page 1 of 4 )
In this article, we will introduce GDI+, focus on basic color transformation programming with GDI+ in C#, and discuss the 4x4 and 5x5 color transformation matrix. We will then offer sample applications to demonstrate how to change existing color components.
Overview of GDI+
GDI+ is the portion of the Windows XP or Windows Server 2003 operating system that provides two-dimensional vector graphics, imaging, and typography. GDI+ improves on the traditional Windows Graphics Device Interface (GDI) by adding new features and by optimizing existing features.
Because it's still a graphics device interface, GDI+ allows programmers to write device-independent applications. As with GDI, GDI+ allows developers to render data on a screen or printer without considering the details of a particular display device. The programmer makes calls to methods provided by GDI+ classes and those methods in turn make the appropriate calls to specific device drivers. GDI+ insulates the application from the graphics hardware, and it is this insulation that allows developers to create device-independent applications.
Let’s take a closer look at the position of GDI+ inside the whole .NET architecture.
Figure 1—GDI+ inside the whole system architecture

As is indicated in Figure 1, GDI+ is one of the modes to develop graphics applications along with GDI and DirectX. As higher wrapper classes, GDI+, like GDI, mainly serves to render graphics, images, and text with more powerful functionalities. Another important difference is that GDI+ adopts a new stateless pattern. This substitutes for GDI, which selects objects into a device context object (i.e. drawing operations within GDI+ are independent of each other).
On the other hand, the services of Microsoft Windows GDI+ can be divided into three categories: 2-D vector graphics, Imaging, and Typography.
2-D vector graphics involves drawing primitives (e.g. lines, curves, and figures) that are specified by sets of points on a coordinate system.
Because certain kinds of pictures are difficult or even impossible to display via vector graphics, various bitmaps are introduced to store various complex images. This is called Imaging. As you image, data structures that store information about bitmaps tend to be more complex than those required for vector graphics, so there are several classes in GDI+ devoted to this method.
Typography is concerned with the display of text in a variety of fonts, sizes, and styles. One of the new features in GDI+ is sub pixel anti-aliasing, which gives text rendered on an LCD screen a smoother appearance.
Next: Introduction to Color Transformation >>
More C# Articles
More By Xianzhong Zhu