I am creating a drawing app. I have succeeded to do everything. When I paint the image with a dark color, some white pixels appear at the edges. I tried to change the value
To be honest it's not really your drawing program's fault so much as the fault of the images being drawn on. The 'white' pixels are actually pale grey, a side effect of the brush tool used to draw the lines in the images. There are two ways around this:
To remove all pale grey pixels from the image and make them white. Using a color select tool and a pencil tool will fix that. The only side effect is that the lines at some points may seem a bit jerky.
To give some leniency when it comes to what colors get painted over. So, instead of just replacing straight white, replace pale greys as well. Any color up to around #CCC (or rgb(204, 204, 204)) should be colored over.
The code for option two is as follows:
if(r >= 204 && g >= 204 && b >= 204 && r === g && g === b){
return true;
}
This simply checks if the pixel is a light greyscale color and returns true if so. Use this instead of your outline color checking function.