I use paint.net and it has this function
All you have to do is use the magic wand on the color you want to change (make sure the tolerance is at 0% or it will also select similar colors, unless you want this of course), select you desired flood mode, and then press backspace to fill the selection with the primary color, or click 'Edit' at the top and then 'Fill Selection'