This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Implementing flood fill Paint programs often offer a flood fill function. When you click a point, the entire region around the point is painted with your selected color. How does this work? Bitmaps A bitmap is a two-dimensional array, where each entry corresponds to the color of one pixel . A pixel (“picture element”) is a little square on the screen. There are different ways to specify color (a typical way is to use 8 bits each for red, green, and blue intensity information, so 24 bits in total). We will assume that the color is an int . To compute the region containing the clicked pixel, we need to define which pixels are “neighbors”. We use the convention that pixels have four neighbors: up, down, left, and right. We do not consider the diagonally adjacent pixels as neighbors. The first algorithm - using recursion The first thing to perform flood filling is remembering the old color of the pixel to be painted. Pixels with the old color would be filled, and other pixels take a role of a boundary. Then we color the pixel, and we seethe old color would be filled, and other pixels take a role of a boundary....
View Full Document
This note was uploaded on 04/20/2010 for the course CS CS206 taught by Professor Lee during the Fall '09 term at 카이스트, 한국과학기술원.
- Fall '09