RegionData Class
Encapsulates the data that makes up a Region object. This class cannot be inherited.
Assembly: System.Drawing (in System.Drawing.dll)
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
Creates a rectangle and draw its to the screen in black.
Creates a region using the rectangle.
Gets the RegionData.
Draws the region data (an array of bytes) to the screen, by using the DisplayRegionData helper function.
public: void GetRegionDataExample( PaintEventArgs^ e ) { // Create a rectangle and draw it to the screen in black. Rectangle regionRect = Rectangle(20,20,100,100); e->Graphics->DrawRectangle( Pens::Black, regionRect ); // Create a region using the first rectangle. System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect ); // Get the RegionData for this region. RegionData^ myRegionData = myRegion->GetRegionData(); int myRegionDataLength = myRegionData->Data->Length; DisplayRegionData( e, myRegionDataLength, myRegionData ); } // THIS IS A HELPER FUNCTION FOR GetRegionData. void DisplayRegionData( PaintEventArgs^ e, int len, RegionData^ dat ) { // Display the result. int i; float x = 20,y = 140; System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",8 ); SolidBrush^ myBrush = gcnew SolidBrush( Color::Black ); e->Graphics->DrawString( "myRegionData = ", myFont, myBrush, PointF(x,y) ); y = 160; for ( i = 0; i < len; i++ ) { if ( x > 300 ) { y += 20; x = 20; } e->Graphics->DrawString( dat->Data[ i ].ToString(), myFont, myBrush, PointF(x,y) ); x += 30; } }
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

