Implementing flood fill

# Implementing flood fill - Implementing flood fill Paint...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the 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

{[ snackBarMessage ]}

### Page1 / 2

Implementing flood fill - Implementing flood fill Paint...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online