
The GetRegionScans bug.Internally, GDI+ regions are stored In a similar format to GraphicsPath objects but may be extracted as a list of rectangles which tile the area covered by the region. It is sometimes useful to have access to these rectangles, one instance being when you would want to convert a GDI+ region into a clipper for the DirectX managed wrappers. Unfortunately, somebody forgot to release an unmanaged memory block in the System.Drawing.Region.GetRegionScans wrapper code and as a result this method leaks and memory block equal to the size of the rectangle array returned by the function. This method does not throw any exceptions and appears to work perfectly but, after a period of time which depends upon the available system resources and the complexity of the region's extracted, the system memory will become so depleted that the computer will cease to function. As yet, there is no work around for this problem except perhaps the possibility of using the GDI region handle which can be obtained from the GDI+ region. This has its own problems inasmuch as every time a GDI region handle is requested a complete new GDI region is constructed from the GDI+ region which internally is stored in a different format. This means that although the work around will indeed provide you with a good GDI+ region from which rectangles may be extracted the time taken to do this is so long that it makes it impractical for use with a high performance graphics program requiring DirectX. NOTE: Microsoft has corrected this defect in the Whidbey system. |
|