Category: Graphics Code  ·  Originally posted March 1, 2009  ·  Last updated February 1, 2011

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?

fill_screenshot

This site - and its many free downloads - are funded by donations from visitors like you.
Please consider a small donation to fund server costs and to help me support my family.
Even $1.00 helps. Thank you!

 

bookmark and share this article

Email this article to a friend Print a copy of this article Subscribe to article comments Bookmark this article on Delicious Submit this article to reddit Submit this article to Digg Submit this article to StumbleUpon Share this article on Facebook Tweet this article

related articles

Discussion (2 comments)

Public comments are closed for this article. Private comments may be submitted using this link.
  1. Excellent and the most apt code for me buddy. Your site is a gold mine of VB6 graphics. Thank you so much..

    By Harison | July 17, 2009, 1:50 am |
    • You’re very welcome. Thanks for the kind words!

      By Tanner | July 19, 2009, 3:40 pm |