Board index » delphi » For Graphic Experts and Gurus: Polygon problem

For Graphic Experts and Gurus: Polygon problem

Hi all of you who understand Windows graphic "things":

I am developping a program in Delphi which writes vectorial maps on the
canvas of a PaintBox. The problem comes up when I Zoom in by a factor
of, say x60 and up, until x10000.

When zoomed coordinates are sent to the Polygon or Polyline functions,
windows returns a GPF error.

I have used Win16 API, Win32 API, Delphi 1 and Delphi 2 functions. If
the coordinates are greater than 20000 the problem always happens.

Of course, designing a clipping function would solve the problem, but it
is supposed to be part of Windows work.

Has anyone any idea of how to get rid of this {*word*193} error?
Please, mail me if you find a solution. :-)

Thanks in advance.
M.Sebares

 

Re:For Graphic Experts and Gurus: Polygon problem


Hi all of you who understand Windows graphic "things":

I am developping a program in Delphi which writes vectorial maps on the
canvas of a PaintBox. The problem comes up when I Zoom in by a factor
of, say x60 and up, until x10000.

When zoomed coordinates are sent to the Polygon or Polyline functions,
windows returns a GPF error.

I have used Win16 API, Win32 API, Delphi 1 and Delphi 2 functions. If
the coordinates are greater than 20000 the problem always happens.

Of course, designing a clipping function would solve the problem, but it
is supposed to be part of Windows work.

Has anyone any idea of how to get rid of this {*word*193} error?
Please, mail me if you find a solution. :-)

Thanks in advance.
M.Sebares

Re:For Graphic Experts and Gurus: Polygon problem


Quote
M. Sebares wrote:

> Hi all of you who understand Windows graphic "things":

> I am developping a program in Delphi which writes vectorial maps on the
> canvas of a PaintBox. The problem comes up when I Zoom in by a factor
> of, say x60 and up, until x10000.

> When zoomed coordinates are sent to the Polygon or Polyline functions,
> windows returns a GPF error.

> I have used Win16 API, Win32 API, Delphi 1 and Delphi 2 functions. If
> the coordinates are greater than 20000 the problem always happens.

> Of course, designing a clipping function would solve the problem, but it
> is supposed to be part of Windows work.

> Has anyone any idea of how to get rid of this {*word*193} error?
> Please, mail me if you find a solution. :-)

> Thanks in advance.
> M.Sebares-----

HI,

I am not a trained Delphi programmer as I usually use Visual C++, but..

Windows has a tendency to give an GPF if you attempt to do 'silly'
things. Attempting to Draw far out of your window is one I recognize.
Windows do clipping by itself, but a proper graphic application should do
some minimum clipping to encure that you only attempt to draw the parts
that are visible. This will also speed up your drawing since clipping on
object levels are far faster than the bit-clipping done by windows. I do
also believe that this will remove your GPF.

Jan Vidar Berger
Case Labs
www.caselabs.com

Re:For Graphic Experts and Gurus: Polygon problem


Quote
"M. Sebares" <m...@lix.intercom.es> wrote:
>[...]
>When zoomed coordinates are sent to the Polygon or Polyline functions,
>windows returns a GPF error.
>I have used Win16 API, Win32 API, Delphi 1 and Delphi 2 functions. If
>the coordinates are greater than 20000 the problem always happens.

Had to zoom some graphs too.. (in D1):
In WinAPI.hlp/Rectangle is said, that the coordinate-DIFFERENCES may
not exceed 32767. (Of course the absolute coordinates too, as they are
Integers). I think this applies to MoveTo/LineTo and the PolyLines
too. Hence your 20000...

Quote
>Of course, designing a clipping function would solve the problem, but it
>is supposed to be part of Windows work.

I eneded up designing a clipping routine for my data, which is a
nontrivial task, if you want to preserve the correnct angles from/to
outliers (You have to handle two clipped points for each point in your
polyline, one for the line to the point, one for the line from the
point...)

--
Matthias Gerstgrasser
m...@sbox.tu-graz.ac.at

Re:For Graphic Experts and Gurus: Polygon problem


In article <322BAAA0.6...@lix.intercom.es>,
"M. Sebares" <m...@lix.intercom.es> says:

Quote

>Hi all of you who understand Windows graphic "things":

>I am developping a program in Delphi which writes vectorial maps on the
>canvas of a PaintBox. The problem comes up when I Zoom in by a factor
>of, say x60 and up, until x10000.

>When zoomed coordinates are sent to the Polygon or Polyline functions,
>windows returns a GPF error.

>I have used Win16 API, Win32 API, Delphi 1 and Delphi 2 functions. If
>the coordinates are greater than 20000 the problem always happens.

>Of course, designing a clipping function would solve the problem, but it
>is supposed to be part of Windows work.

>Has anyone any idea of how to get rid of this {*word*193} error?
>Please, mail me if you find a solution. :-)

>Thanks in advance.
>M.Sebares

Try using another (bugfree) graphics driver.
What happens is, that any graphics (screen, printer) driver can tell
windows whether it is capable to handle clipping. If it does so,
Windows believes it can do so faster then GDI, and trusts the driver
to do so in a correct way.

If this happens to be the case, please notify the manufacturor.

Bye,
Zweitze.

-----------------------------------------------------------------------
  Zweitze de Vries                           zwei...@cyco.nl
  Cyco Software Development
  Handelskade 49
  Rijswijk, Netherlands                      (+31) 70 3954179

Re:For Graphic Experts and Gurus: Polygon problem


In article <322BAAA0.6...@lix.intercom.es>, "M. Sebares"
<m...@lix.intercom.es> writes

Quote
>Hi all of you who understand Windows graphic "things":

>I am developping a program in Delphi which writes vectorial maps on the
>canvas of a PaintBox. The problem comes up when I Zoom in by a factor
>of, say x60 and up, until x10000.

>When zoomed coordinates are sent to the Polygon or Polyline functions,
>windows returns a GPF error.

>I have used Win16 API, Win32 API, Delphi 1 and Delphi 2 functions. If
>the coordinates are greater than 20000 the problem always happens.

>Of course, designing a clipping function would solve the problem, but it
>is supposed to be part of Windows work.

>Has anyone any idea of how to get rid of this {*word*193} error?

It sounds as though your coordinates are wrapping around. The GDI
coordinate system on both Windows 3.1 and Windows 95 is 16-bit - ie you
can only have coordinates in the range +/-32k. Only Windows NT has a 32-
bit GDI coordinate system.

The GPF will probably be due to an error in your code when it
"unexpectedly" comes across negative coordinates. Run your program under
the de{*word*81} and find out why it's crashing!

Chris

--------------------------------------------------------------------------
 Chris Marriott, Warrington, UK      | Author of SkyMap v3 award-winning
 ch...@chrism.demon.co.uk            | shareware Win31/Win95 planetarium.
            For full info, see http://www.execpc.com/~skymap  
      Author member of Association of Shareware Professionals (ASP)
--------------------------------------------------------------------------

Re:For Graphic Experts and Gurus: Polygon problem


Quote
Matthias Gerstgrasser wrote:

> In WinAPI.hlp/Rectangle is said, that the coordinate-DIFFERENCES may
> not exceed 32767. (Of course the absolute coordinates too, as they are
> Integers). I think this applies to MoveTo/LineTo and the PolyLines
> too. Hence your 20000...

Thank Matthias for your answer. Now I am working with D2 and W95, where
graphic coordinates are stored in 32 bit variables. I wonder if the same
restriction also applies in WinApi32. :-?

Quote
> I ended up designing a clipping routine for my data, which is a
> nontrivial task, if you want to preserve the correnct angles from/to
> outliers (You have to handle two clipped points for each point in your
> polyline, one for the line to the point, one for the line from the
> point...)

Well, I suppose I'll have to develop such a routine, which seems to be a
nontrivial task at all (I am Zooming In up to 100000 times) :)

Thanks again, Matthias.
M. Sebares
Canary Islands, Spain.

Re:For Graphic Experts and Gurus: Polygon problem


Quote
"M. Sebares" <m...@lix.intercom.es> wrote:
>Matthias Gerstgrasser wrote:

>> In WinAPI.hlp/Rectangle is said, that the coordinate-DIFFERENCES may
>> not exceed 32767. (Of course the absolute coordinates too, as they are
>> Integers). I think this applies to MoveTo/LineTo and the PolyLines
>> too. Hence your 20000...

>Thank Matthias for your answer. Now I am working with D2 and W95, where
>graphic coordinates are stored in 32 bit variables. I wonder if the same
>restriction also applies in WinApi32. :-?

Yes. Graphics coordinates in Win95 are always restricted to +/- 32767, from
either a 16-bit program or a 32-bit program.  This is in part because all
the display drivers are still 16-bit.

-- Tim Roberts, t...@iia.com
   Providenza & Boekelheide, Inc.

Other Threads