ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Problems with DiffRgn


Q: I'm having a bit of a problem with DiffRgn. I start out with a "wide open" rectangular region (-32767, -32767, 32767, 32767) and then use DiffRgn to subtract a group of smaller rectangles from it. When I'm done, the bounding box of the region isn't what it should be. Any idea what's happening?

A: What you need to do is create your clipping region so that it's not quite wide open (bottom and right coordinates of 32766 will work). If you do this, all your DiffRgn calculations will work fine.

While this isn't explicitly documented anywhere, it does seem to be a quirk in the way regions work. Due to the internal storage format of regions, the number 0x7FFF (32767) causes problems if it appears as a point inside a region. 0x7FFF is used as a flag in the internal region data structure to signify a "barrier." When this flag is used as a data point in a nonrectangular region, region parsing becomes completely screwed up.

QuickDraw tries to catch the creation of regions that will be poorly formed and turn them into properly formed (but slightly incorrect) regions, but it isn't 100% successful.

[Sep 15 1995]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.