Board index » delphi » Large Polygon 65k points limit in Win32?

Large Polygon 65k points limit in Win32?

I'm using Canvas.Polygon to draw map area. But when the
Polygon is large (more than 65k points), the function doesn't
work (the extra points disapear). I don't know if it is the
Polygon() or the Slice() function.

I'm using Delphi 7. I supposed this 65k limit was gone
in Win32....

Any idea will be appreciated.

Omar

 

Re:Large Polygon 65k points limit in Win32?


Quote
"Omar Reis" <o...@tecepe.com.br> wrote in message

news:3E1EDE7C.49CB2406@tecepe.com.br...

Quote
> I'm using Canvas.Polygon to draw map area. But when the
> Polygon is large (more than 65k points), the function doesn't
> work (the extra points disapear). I don't know if it is the
> Polygon() or the Slice() function.

> I'm using Delphi 7. I supposed this 65k limit was gone
> in Win32....

> Any idea will be appreciated.

For compatibility with Win9X, I split my calls into 16K chunks.... (Delphi
5)

Cheers,
David

Re:Large Polygon 65k points limit in Win32?


Quote
Omar Reis wrote:
> David J Taylor wrote:
> > Omar Reis wrote:
> > > I'm using Canvas.Polygon to draw map area. But when the
> > > Polygon is large (more than 65k points), the function doesn't
> > > work (the extra points disapear). I don't know if it is the
> > > Polygon() or the Slice() function.

> > For compatibility with Win9X, I split my calls into 16K chunks....
(Delphi
> > 5)

> This is a good idea. But my Polygons have a
> different color border and splitting causes anoying
> lines to appear inside the polygon.

> Is there any other way around this problem ?

Is it acceptable to merge polygon vertices that are very close together?

-Gary

Re:Large Polygon 65k points limit in Win32?


Quote
Gary Williams wrote:
> Omar Reis wrote:
> > David J Taylor wrote:
> > > Omar Reis wrote:
> > > > I'm using Canvas.Polygon to draw map area. But when the
> > > > Polygon is large (more than 65k points), the function doesn't
> > > > work (the extra points disapear). I don't know if it is the
> > > > Polygon() or the Slice() function.

> > > For compatibility with Win9X, I split my calls into 16K chunks....

> > This is a good idea. But my Polygons have a
> > different color border and splitting causes anoying
> > lines to appear inside the polygon.

> > Is there any other way around this problem ?

> Is it acceptable to merge polygon vertices that are very close together?

This is also a good idea. My polygons are mapped from world
coordinates to canvas coordinates acording to the current view
port (i.e. zoom state).

I could see what points are very close together when zoomed out
(ex. same screen x and y). I would also have to clip the polygon to the
screen rectangle when the user does a zoom in, removing the
segments that are not visible.

But all these calculations would slow the rendering considerably.
And in the end the problem would not be solved. Some polygons
would still not be rendered correctly.

I wonder if anyone knows where this limitation comes from ?
I would like to write a Rectangle procedure that actually works...

Omar

Re:Large Polygon 65k points limit in Win32?


Sorry,
I made a mistake in the previous post: It is the Polygon
procedure that is not working....

Omar

Quote
Omar Reis wrote:
> Gary Williams wrote:

> > Omar Reis wrote:
> > > David J Taylor wrote:
> > > > Omar Reis wrote:
> > > > > I'm using Canvas.Polygon to draw map area. But when the
> > > > > Polygon is large (more than 65k points), the function doesn't
> > > > > work (the extra points disapear). I don't know if it is the
> > > > > Polygon() or the Slice() function.

> > > > For compatibility with Win9X, I split my calls into 16K chunks....

> > > This is a good idea. But my Polygons have a
> > > different color border and splitting causes anoying
> > > lines to appear inside the polygon.

> > > Is there any other way around this problem ?

> > Is it acceptable to merge polygon vertices that are very close together?

> This is also a good idea. My polygons are mapped from world
> coordinates to canvas coordinates acording to the current view
> port (i.e. zoom state).

> I could see what points are very close together when zoomed out
> (ex. same screen x and y). I would also have to clip the polygon to the
> screen rectangle when the user does a zoom in, removing the
> segments that are not visible.

> But all these calculations would slow the rendering considerably.
> And in the end the problem would not be solved. Some polygons
> would still not be rendered correctly.

> I wonder if anyone knows where this limitation comes from ?
> I would like to write a Polygon  procedure that actually works...

> Omar

Re:Large Polygon 65k points limit in Win32?


Quote
"Omar Reis" <o...@tecepe.com.br> wrote in message

news:3E1F08BD.75E71587@tecepe.com.br...

Quote
> Sorry,
> I made a mistake in the previous post: It is the Polygon
> procedure that is not working....

> Omar

Actually, it is PolyLine not polygon that I spilt into multiple 16K
segements.  Can you use PolyLine rather than Polygon?

Cheers,
David

Re:Large Polygon 65k points limit in Win32?


Quote
David J Taylor wrote:
> "Omar Reis" <o...@tecepe.com.br> wrote in message
> news:3E1F08BD.75E71587@tecepe.com.br...
> > Sorry,
> > I made a mistake in the previous post: It is the Polygon
> > procedure that is not working....

> > Omar

> Actually, it is PolyLine not polygon that I spilt into multiple 16K
> segements.  Can you use PolyLine rather than Polygon?

I think both functions have the same point number limitation.
I use Polygon because I want to fill the polygon interior with
a different color.

Omar

Re:Large Polygon 65k points limit in Win32?


Hi Omar,

Quote
> The MSDN page also suggests splitting the large
> polygon in multiple smaller polygons, which is
> inadequate in the case where the Pen and
> solid brush have different colors.

I had the same problem, and I solved it by using successive Polyline calls, and
then filling the interior of the resulting polygon with FloodFill.

The problem I had was that it was not easy to find the right point(s) to call
Floodfill from, especialy when the polygon has a complicated outline. Of course
if you know what the form will look like, you can define the optimal point(s) in
function of that.

You could also use a similar technique in a slightly different way:
1. first draw the "filling" by cutting your polygon into smaller polygons and
drawing them with a solid brush, but with Pen.Style := psclear;
2. draw successive polylines with the solid pen to make the outline.

Of course if your polygon has a complex form (e.g. intersecting sides) those two
techniques are hard to apply...

Good luck

Thrse

Re:Large Polygon 65k points limit in Win32?


If you do the outline separate from the fill you could split the
polygons and
then do the outline with polylines.

Mitch

Re:Large Polygon 65k points limit in Win32?


"Omar Reis" <o...@tecepe.com.br> skrev i meddelandet
news:3E1F2503.E1E8084A@tecepe.com.br...

Quote
> The URL you sent solved the mistery. The limit is in the
> Win32 Polygon function (actually its only 16k points).

> Delphi's Win32 help does not menion this limit.
> The MSDN page also suggests splitting the large
> polygon in multiple smaller polygons, which is
> inadequate in the case where the Pen and
> solid brush have different colors.

Not necessarily inadequate. Split your large polygons and draw the parts
with Pen = Brush, then draw the edgelines with split polylines.

Also note that there are faster ways to draw a polygon (edge or filled) than
with GDI calls!

I replaced Polygon and Polyline in my BlockCAD program with 'homebrew'
polygon routines from Graphical Gems, and it got faster 2-100 times, the 100
for transparent polys though.

Code is a bit uglier, though...
--
Anders Isaksson, Sweden
BlockCAD:  http://user.tninet.se/~hbh828t/proglego.htm
Gallery:   http://user.tninet.se/~hbh828t/gallery/index.htm

Re:Large Polygon 65k points limit in Win32?


Quote
"Omar Reis" <o...@tecepe.com.br> wrote in message news:3E1F2503.E1E8084A@tecepe.com.br...
> So I'm back to the drawing board, but at
> least I know why it isn't working...

Sounds like you need a Polgygon rendering engine that has no practical limts :)

I build those sort of things...

Joe
--
Delphi, graphics, and printing specialist available - $35/hr
http://www.code4sale.com/codeit/index.htm

Re:Large Polygon 65k points limit in Win32?


How do you know if the code is uglier :)

Windows GDI is and was never open source! Who knows what mess is behind the
facade :) Perhaps one of the best kept secrets of Redmont..

Kind regards,

Nils

Quote
"Anders Isaksson" <isaksson.et...@REMOVEebox.tninet.se> wrote in message

news:3e200a11@newsgroups.borland.com...
Quote
> "Omar Reis" <o...@tecepe.com.br> skrev i meddelandet
> news:3E1F2503.E1E8084A@tecepe.com.br...
> > The URL you sent solved the mistery. The limit is in the
> > Win32 Polygon function (actually its only 16k points).

> > Delphi's Win32 help does not menion this limit.
> > The MSDN page also suggests splitting the large
> > polygon in multiple smaller polygons, which is
> > inadequate in the case where the Pen and
> > solid brush have different colors.

> Not necessarily inadequate. Split your large polygons and draw the parts
> with Pen = Brush, then draw the edgelines with split polylines.

> Also note that there are faster ways to draw a polygon (edge or filled)
than
> with GDI calls!

> I replaced Polygon and Polyline in my BlockCAD program with 'homebrew'
> polygon routines from Graphical Gems, and it got faster 2-100 times, the
100
> for transparent polys though.

> Code is a bit uglier, though...
> --
> Anders Isaksson, Sweden
> BlockCAD:  http://user.tninet.se/~hbh828t/proglego.htm
> Gallery:   http://user.tninet.se/~hbh828t/gallery/index.htm

Other Threads