Drawing pixel to pixel
There're several places you could optimize your code.

First, though, I suggest profiling your current code, so you'd know which are your bottlenecks, and where you should concentrate your efforts. 

The detection of the black pixels is a CPU intensive process, which means it could benefit from the techniques mentioned above.

The copying of the black pixels, on the other hands, is an I/O intensive process, which you can optimize in two ways:


Instead of copying the pixels as they are discovered to the other window, build a data structure - in memory - that represents the data for this other window, and then do the copy as one memory image copying, instead of a set of single pixels. Or,
Break the pixel copying into several threads/processes that will work in parallel. Note that this may not be possible, depending on your algorithm.