- Tanner Helland (dot) Com - http://www.tannerhelland.com -

Code for Filling Image Regions (VB6)

Posted By Tanner On March 1, 2009 @ 4:56 pm In Graphics Code,Programming | Comments Disabled

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?


Article printed from Tanner Helland (dot) Com: http://www.tannerhelland.com

URL to article: http://www.tannerhelland.com/649/fill-image-regions/

All text copyright © 2008 Tanner Helland. To reduce paper and ink usage, all comments, images, and videos have been suppressed on this printing.