Reader Level:

Rectangle and Regions in GDI+

By Mahesh Chand on Jan 08, 2010
In this article I will explain about Rectangle and Regions in GDI+.

This article has been excerpted from book "Graphics Programming with GDI+".

In this article we will discuss addition functionality of rectangles and regions.

We will cover the following key topics:

  • . NET Framework objects that work with rectangles and regions and their members.
  • Graphics class members that work with rectangle and regions
  • Writing application using objects
  • The Rectangle structure and its members
  • The Region class and its members
  • Invalidating and clipping regions
  • Examples of real-world application using regions and rectangles

A rectangle has three properties: starting point, height, and width. Figure 6.1 shows these properties where the starting point is the top left.

Suppose you wanted to draw a rectangle from point (1,2) with height 7 and width 6. The final rectangle would look like Figure 6.2.

The filled rectangle occupies the entire within the range of its height and width.

Figure 6.1.gif

FIGURE 6.1: A rectangle


FIGURE 6.2: A rectangle with starting point (1,2), height 7, and width 6

The Rectangle Structure

A rectangle object stores the top left corner and height and width of a rectangle region. In this section we will see how to create and use the rectangle structure.


Hope the article would have helped you in understanding
Rectangle and Regions in GDI+. Read other articles on GDI+ on the website.

bookGDI.jpg This book teaches .NET developers how to work with GDI+ as they develop applications that include graphics, or that interact with monitors or printers. It begins by explaining the difference between GDI and GDI+, and covering the basic concepts of graphics programming in Windows.

Mahesh Chand
Mahesh Chand

C# Corner founder, 10-times Microsoft MVP, technical author, and software architect. Mahesh authored his first book, A Programmer’s Guide to ADO.NET in C# with APress at the age of 25. C# Corner is a memb... Read more