First of all, I would like to thank a great team at Addison-Wesley, including Stephane Thomas, John D. Ruley, Michael Mullen, Stephanie Hiebert, and Tyrrell Albaugh, all of whom were very helpful from time to time.

Technical reviewers played a vital role in improving the technical aspects of this book. Their comments and suggestions made me think from various different programming perspectives. I would like to thank technical reviewers Charles Parker, Min Liu, Gilles Khouzam, Jason Hattingh, Chris Garrett, Jeffery Galinovsky, Darrin Bishop, and Deborah Bechtold.

I would also like to thank John O'Donnell for his contribution to the printing chapter of the book (Chapter 11).


By introducing the .NET Framework to the programming world, Microsoft has changed the perspective and vision of programming and programmers. Unlike previous programming environments, the .NET Framework is designed with the future of software development in mind. Besides introducing the new C# language and significant additions to Visual Basic .NET and other languages, the .NET Framework provides many new tools and utilities that make a programmer's life easier.

Languages, tools, and utilities aside, the .NET Framework library is the real power of the .NET Framework. It's an object-oriented class library that defines an interface to interact with various programming technologies. Any programming language that is designed to work with the .NET Framework can access the library, which makes a programmer's life easier because the methods and properties defined in the library are the same, regardless of the language.

Each class defined in the .NET Framework library belongs to a particular namespace—a logical unit that is used to separate a particular programming interface from others. For example, the System.Windows.Forms namespace defines classes that are used for Windows Forms development. System.Data and its subnamespaces define classes that are used for database development (ADO.NET).

GDI+ is the next-generation graphics device interface, defined in System.Drawing and its subnamespaces. This book focuses on how to write graphical Windows and Web applications using GDI+ and C# for the Microsoft .NET Framework.

Who Is This Book For?

This book is designed for intermediate developers who want to write graphics applications for the .NET Framework using GDI+ and C#. Here are the topics we will cover:

  • What GDI+ is all about, and how it differs from GDI

  • How GDI+ works, and where it is defined in the .NET Framework library

  • How to draw text, lines, curves, rectangles, ellipses, and other graphics shapes in GDI+

  • How to fill rectangles, ellipses, and other closed curves with different colors, styles, and textures

  • Painting and drawing in .NET

  • Viewing and manipulating images

  • How Windows Forms and Web Forms are related to drawing

  • How to write Web-based graphics applications

  • Printing in .NET

  • Transforming graphics objects, colors, and images

  • Interactive color blending and transparent colors

  • Using GDI in .NET applications

  • Precautions to take when writing GDI+ applications

  • Optimizing the performance of GDI+ applications


There are some things you should know before beginning this book:

  • Language: This book is written in C#, but developers who want to use GDI+ with other .NET Framework languages—including Visual Basic .NET—can also use this book. Because C# and VB.NET share the same .NET Framework library, there isn't much difference aside from the language syntaxes. Knowledge of C# or VB.NET is not a requirement, however. If you are a C++ developer, you should have no difficulty using this book.

  • Framework: I used Visual Studio .NET to develop and test the samples in this book. Knowledge of Visual Studio .NET and basics of the .NET Framework is a requirement.

  • Basics of graphics programming: A basic understanding of graphics programming is a plus but is not mandatory.

  • GDI programming experience: Experience with GDI programming is a plus but is not mandatory.