KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q44054: QuickC: _floodfill May Fail When Filling Color 0

Article: Q44054
Product(s): See article
Version(s): 2.00
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist2.00 | mspl13_c
Last Modified: 18-MAY-1989

The graphics function _floodfill fails under any graphics mode with
more than two colors when all of the following occur:

1. A region enclosed by a border color is filled.

2. A shape with the color of the border color is enclosed within that
   region.

3. The color being _floodfilled is 0.

When _floodfill encounters this enclosed shape, it slows down
considerably. When it completes filling, the program hangs. Executing
the following program demonstrates this problem:

   #include <graph.h>

   #define BORDER 15

   unsigned char mask[] = {255,1,1,1,1,1,1,1};

   void main (void)
    { _setvideomode (_VRES16COLOR);

      /* Draw the border. */
      _setcolor (BORDER);
      _ellipse (_GBORDER,10,10,630,340);

      _setfillmask ((char far *) mask);

      /* Remove drawing this interior shape and the program works. */
      _setpixel (323,84);

      /* This _floodfill is just for looks. */
      _setcolor (2);
      _floodfill (320,190,BORDER);

      _setcolor (0);

      /* This line will slow down and hang. */
      _floodfill (320,190,BORDER);
    }

This problem is not related to the color currently mapped to color 0
(black by default). If you must _floodfill black, remap another color
to black and _floodfill that color. For example, to patch the above
program, replace

   _setcolor (0);

with the following:

   _remappalette (8,_BLACK);
   _setcolor (8);

This also is a problem with Optimizing C Versions 5.00 and 5.10 when
_floodfilling any color under the circumstances described above -- not
just color 0.
Microsoft is researching this problem and will post new information as
it becomes available.

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.