Q65590: _Floodfill() Doesn’t Completely Fill Areas with Patterns
Article: Q65590
Product(s): See article
Version(s): 6.00
Operating System(s): MS-DOS
Keyword(s): ENDUSER | s_quickc | mspl13_c
Last Modified: 24-SEP-1990
The sample code below draws two circles that are cut in half with a
line. There is a small gap (2 pixels) in the line. When _floodfill()
is used to fill the circle with a solid color, it fills the entire
circle. When _floodfill() is used to fill the circle with a pattern,
it fills only half of the circle.
In this instance, the two-pixel gap in the line corresponds to the gap
in the fill pattern. This causes _floodfill() to treat it as a solid
line and fill only half the circle.
To fill the entire circle with the pattern, create a second
_floodfill() with a point on the other side of the line, as in the
commented section of the code below:
Sample Code
-----------
#include <conio.h>
#include <graph.h>
#include <time.h>
#include <stdlib.h>
#include <stddef.h>
void main(void)
{
unsigned char fill[] = {0x88,0x22,0x88,0x22,0x88,0x22,0x88,0x22};
if( !_setvideomode( _MAXRESMODE ) )
exit(1);
_setfillmask( NULL ); /* Fill circle with a solid color */
_setcolor(2);
_ellipse( _GBORDER, 50, 100, 250, 300 );
getch();
_moveto( 50, 200 );
_lineto( 248,200 ); /* Line with a 2 pixel gap */
getch();
_setcolor(4);
_floodfill( 100, 210, 2); /* Fill the circle with a solid color */
getch();
_setfillmask( fill ); /* Fill circle with a pattern */
_setcolor(2);
_ellipse( _GBORDER, 350, 100, 550, 300 );
getch();
_moveto( 350, 200 );
_lineto( 548, 200 ); /* Line with a 2 pixel gap */
getch();
_setcolor(4);
_floodfill( 400, 210, 2); /* Fill half of the circle with a pattern */
/* _floodfill( 400, 180, 2); This _floodfill() will fill in the other */
/* half of the circle with a pattern. */
getch();
_setvideomode( _DEFAULTMODE );
}
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.