You can get to the scan line data in a region using the
Region.GetRegionScans method.
#1 sort the scans into X and Y order.
#2 Step through the scans and see if the current scan overlaps with the
previous one. If yes, add it to the list that it overlaps with, if
not, start a new list.
#3 continue to do this for all scans
#4 check all scans in all regions for overlap with scans in other
regions, if any overlap, combine the two lists, do this until you cannot
reduce the number of lists.
the resulting lists represent separate and contiguous areas

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Hi,
>
[quoted text clipped - 26 lines]
> Regards,
> Kris Wragg
Kristopher Wragg - 16 Feb 2007 11:12 GMT
Hi,
Thanks for your reply, I've had an attempt at trying to do what you
said but so far haven't got it working correctly.
It seems an awfully long winded and processor intensive operation to
do something that should be fairly simple.
What I tried was to first get all the RectangleF's from the
GetRegionScan, then sorted them in order of Y then X.
Then I looped through them seeing whether rect[i] intersects with
rect[i+1] when rect[i+1] had been moved by -1,-1 then inflated by 2,2.
This worked to an extent but wasn't a very good solution, is there a
more optimal way of doing this? or perhaps you have an example of it
being used in practise?
many thanks,
Kris Wragg
Bob Powell [MVP] - 16 Feb 2007 13:15 GMT
I used this algorithm to find out how many different glyphs were on a
page of text and colour them with a different colour.
I didn't mess about inflating the rectangles but just looked to see if
any rectangle in the current Y+1 had a left-right overlap with the
current rectangle. You just need to see if any left-right boundary falls
in the length of the other rectangle.
I seem to remember processing a page of text in about 15 seconds.

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Hi,
>
[quoted text clipped - 16 lines]
> many thanks,
> Kris Wragg