Recent

Author Topic: FloodFill  (Read 475 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 350
FloodFill
« on: September 24, 2024, 09:58:20 am »
Any way to know the size of area that will be filled ?
lazarus 3.2-fpc-3.2.2-win32/win64

RayoGlauco

  • Full Member
  • ***
  • Posts: 197
  • Beers: 1567
Re: FloodFill
« Reply #1 on: September 24, 2024, 10:34:23 am »
Because of the way the FloodFill algorithm works, I don't think it's possible to know in advance what area will be filled, except in particular cases, where you have more information than the algorithm requires. In fact, the algorithm only asks for the starting point and doesn't ask for any geometric information about the area to be examined.
To err is human, but to really mess things up, you need a computer.

wp

  • Hero Member
  • *****
  • Posts: 12787
Re: FloodFill
« Reply #2 on: September 24, 2024, 11:41:58 am »
There is no way to measure the floodfill area without actually performing the floodfill. But during the floodfill you simply can count the pixels which are set. The attached project does this by means of a derived TLazIntfImage which overrides the inherited SetInternalColor method to increment the pixel counter. The image gets a copy of the bitmap to be floodfilled so that the measuring process can be running in a hidden way.

 

TinyPortal © 2005-2018