Non-recursive flood fill algorithm --------------------------------------------Make an array to hold pointers to the pixels (or whatever). If your language can't handle pointers, use coordinates, but be aware that the program will be relatively very slow. For now I will assume that the array is big enough for any number of pixels. There is a trick you can use to shorten it, which I won't go into just now. Put your first pixel in array[0]. Mark it 'checked'. You need some way of marking and unmarking the pixels - changing the colour would do. You need two pointers or indices: pCurrent points to array[0] pSave points to array[1] Do the following: Mark all correctly-coloured pixels adjacent to *pCurrent as checked, and store them at pSave, incrementing pSave each time. Then increment pCurrent. [Example: if you have three pixels to add, pCurrent goes on 1 and pSave goes on 3. If there are no correctly-coloured pixels adjacent to the current pixel, pCurrent goes on 1 while pSave stays the same.] Now just keep going until pCurrent catches up with pSave, and you are done. array contains pointers to all the pixels - don't forget to uncheck them. You can shorten the array by using cyclic pointers that go back to the start. You will lose the list of pixel pointers, but this doesn't matter in the classic flood-fill case. The size of array needed is probably only a few times the maximum diameter of the area, but I don't know the exact limit.