dotnet drawing api:
Hello,
I am in need to find specific point in region. To be exact:
Suppose, we have region like the one below
__________
| _____|
| |
| |
_____* <- this is the point (*) I am looking for, if one thought of
region as a block of lines and attached to each line bounding rectangle
then the point would be at (rectangle.Right, Rectangle.Top)
Another example could be:
______________
| |
| |
_____________* <- (this is the point) This case could be analyzed in
the same way as the one above, yielding point marked with *
I tried to win the problem with using GetRegionScans and computing the
point by comapring by procedure like:
RectangleF bounds = region.GetBounds(graphics);
if (char.IsWhiteSpace(lastCharInRegion))
{
if (lastCharInRegion == '\n')
return new PointF(bounds.X, bounds.Bottom);
}
float highestX = float.MinValue;
float lowestY = float.MaxValue;
foreach(RectangleF rectangle in
region.GetRegionScans(transformation))
{
if (rectangle.Bottom == bounds.Bottom)
{
highestX = Math.Max(higestX, rectangle.Right);
lowestY = Math.Min(lowestY, rectangle.Top);
}
}
return new PointF(highestX, lowestY);
but hte procedure works only if hard assumptions are taken:
GetRegionScans returns rectangles horizontally ordered, and each
rectangle has height of imaginary line - which might not be the case as
documentation do not specify any ordering or properties of returned
rectangles. Also, I've heard of GetRegionScnas bug which distracted me
from using it.
Another approach I thought of would not use any region at all, except
ectangular ones (regions are returned from MeasureCharacterRegions
method, so it is easy to achieve), but I am quite sure it would have
made my procedure less effective.
What is the best solution to my problem, in your opinion?