PRC9108004: C 5.1 _ellipse() May Be Two Pixels Off

ID Number: Q75325

5.10

MS-DOS

buglist5.10 fixlist6.00

Summary:

PROBLEM ID: PRC9108004

SYMPTOMS

In the Microsoft C Compiler version 5.1 and the Microsoft QuickC

Compiler versions 1.0, 1.01, 2.0, and 2.01, the _ellipse() function

may draw the ellipse two pixels off from the expected coordinates.

This can be seen when floodfilling a region bounded by the ellipse

and a line on y2. The floodfill will bleed out of what should be

an enclosed region.

CAUSE

The function _ellipse() takes the following parameters:

_ellipse( SHORT control, SHORT x1, SHORT y1, SHORT x2, SHORT y2 )

The pairs (x1, y1), (x2, y2) define a rectangle that bounds the

ellipse; however, the ellipse is drawn two pixels above the y2

coordinate.

RESOLUTION/STATUS

This problem can be demonstrated in any video mode, but will not

happen with every possible ellipse. See the sample code below.

Microsoft has confirmed this to be a problem in C version 5.1 and in

QuickC versions 1.0, 1.01, 2.0, and 2.01 (buglist1.00, buglist1.01,

buglist2.00, buglist2.01). The problem was corrected in C version

6.0 and in QuickC version 2.5 (fixlist2.50).

More Information:

The following code demonstrates the problem.

Sample Code

-----------

/* Compile options needed: none

*/

#include <graph.h>

#include <conio.h>

void main ( )

{

int x1=0, y1=0, x2=639, y2=349;

_setvideomode ( _ERESCOLOR );

// Draw the ellipse and the rectangle that bounds it

_setcolor ( 15 );

_rectangle ( _GBORDER, x1, y1, x2, y2 );

_ellipse ( _GBORDER, x1, y1, x2, y2 );

// Pick a portion between the rectangle and the ellipse

// (lower left corner) to floodfill in red.

_moveto ( x1+1, y2-1 );

_setcolor ( 12 );

// The fill should not 'bleed' beyond the lower left corner.

_floodfill( x1+1, y2-1, 15 );

while( !kbhit( ) );

}

Additional reference words: 1.00 2.00 2.50 5.10 6.00