void boundaryFill(int x, int y, int fill, int bound)
{
// define position
int pos = y * width + x;
// define sample container
int _cclr = 0;
// check for correct size
if (pos < (pixels.length - 1) && pos > 0)
{
// load a sample
_cclr = pixels[pos];
// System.out.println(Integer.toHexString(_cclr));
// check if sample is already filled or is a bound
if (_cclr != fill && _cclr != bound)
{
pixels[pos] = fill;
boundaryFill(x + 1, y, fill, bound);
boundaryFill(x, y + 1, fill, bound);
boundaryFill(x - 1, y, fill, bound);
boundaryFill(x, y - 1, fill, bound);
}
}
}