create fill {pixel count}

01-19-2005, 07:25 AM
Is there a way I can count the number of pixils in an area that was filled by the floodfill in visual basic

Hopefully this isn't a homework assignment...

But anyway you don't need api functions to use different fillstyles...
Check out the zip attachment to this post:

Although it doesn't show how to floodfill an irregular area, it does demo the DrawStyles and FillStyles available in VB.

And if you type:

vb floodfill Google you will find a VBHelper page that will show you how to use the FloodFill API to fill irregular areas.

01-19-2005, 03:12 PM
Welcome to the board.

An Interesting question.

Since the shape can be irregular, and the fill color might exist in places other than the area filled, you
can't just loop looking for pixels of the fill color.
I don't believe I've heard of any fill routine that keeps track of the number of pixels modified.

My first guess at an approach would be to have a copy of the picture before the fill. Then after the
fill, you could use bitblt to XOR (vbSrcInvert raster OP) the after picture to the before picture. All
the pixels that were unchanged would become black. You could then loop through the resulting
picture and count all the non-black pixels.

A second approach would be to use the API (don't have Windows available at the moment so won't
search for the specific API, but examples of getting pixels values from a bitmap can be
found in this forum (as well as other places)) to get a copy of the pixels in an array before the fill. Then get a
copy in an array of the pixels after the fill. Then you can loop throught the array comparing the
values and counting the differences.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum