To give you an ad-free browsing experience, this website is completely funded by donations. If you use the information in this article to solve a problem, entertain yourself, or otherwise improve your life, please consider a small donation to help pay for server costs. Many thanks, and enjoy the site!

Graphics Code

Code for Filling Image Regions (VB6)

This little program demonstrates two key graphics programming principles:

1) Simple “painting” code – basically, connecting a series of lines together as the user drags their mouse around.

2) An implementation of the hard-to-find (and poorly documented) API call for filling a contiguous region of an image. (Photoshop users should know this as the “paint bucket” tool.)

The API call used to perform the fill operation is ExtFloodFill, with a VB6 declaration and parameters like so:

Private Declare Function ExtFloodFill Lib "GDI32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long

To use the program, draw several lines using the left mouse button, then fill contiguous regions (with random colors) via the right button. Simple, eh?

Download Code (7 kb)

fill_screenshot

 

BSD License
All source code in the above zip file has been released under a BSD License.

 

Related articles:

Discussion (Oldest Comments Displayed First)

One comment on “Code for Filling Image Regions (VB6)”

  1. Excellent and the most apt code for me buddy. Your site is a gold mine of VB6 graphics. Thank you so much..

    Posted by Harison | July 17, 2009, 1:50 am

Post a comment

Feel free to use any of these tags in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>