I am currently implementing a method that accepts two raster objects. We can assume that these objects have the same size, etc. The method return is a list of pixel changes (this is stored in a makeshift object). This is being developed in iterative order, so the current implementation was basic ... just work through each pixel and compare it with its copy. This way of generating changes is slower than acceptable (500 ms or so), so I'm looking for a faster process.
The ideas that crossed my mind are to split the image into stripes and start each comparison in a new stream or compare screen areas as objects at first, and then only examine them in detail as necessary.
current code for your understanding ...
for (int x = 0; x < screenShotBMP.Width; x++) { for (int y = 0; y < screenShotBMP.Height; y++) { if (screenShotBMP.GetPixel(x, y) != _PreviousFrame.GetPixel(x, y)) { _pixelChanges.Add(new PixelChangeJob(screenShotBMP.GetPixel(x,y), x, y)); } } }
As you subtract from the code, the concept of the class in question is to take a screenshot and generate a list of pixel changes from a previously taken screenshot.
source share