I am trying to compare two byte arrays in memory and produce a data structure to hold the differences so that with byte array B and the data structure holding the differences it is possible to recreate byte array A.
The size of the byte arrays are always identical and are relatively small. The byte arrays represent bitmaps which typically range in size from 1000x1000x32 to 128x128x32.
The speed and efficiency (from a cpu time pov) at which the data-structure-that-holds-the-differences and the second byte array can be combined/used to reconstruct byte array A is of the highest importance. It is not as important that the generation of the difference object be as efficient.
Right now my solution will be to use a binary search + md5 hashing approach to build a list of the smallest units of difference inside the image and package the raw byte data with a reference of its offset inside byte array A.
I.e. I generate the hash for Image A's byte array and compare it to the hash of Image B's byte array, if it doesn't match I horizontally split the image in half and hash each block then compare those hashes between the images, this process is then repeated recursively until all blocks that don't match hit a minimum size like 32x32x32 and/or a max number of splits. Once a block is marked as matching it is no longer part of the recursive search. Once all the differences have been identified they will be added to a list of changes and that list is then the difference object.
Are there any built in ways to efficiently produce the results I'm looking for? Or are there any libraries that would do the job?
Notes:
- This is a learning project (for WCF, WPF and a number of other technologies),
- It is a VNC style system - so the images are snapshots of a window and will be sent over a LAN connection.
- The reason the reconstructing of Byte array A must be efficient is that a client can connect to more than one server and each server can serve more than one window, so a client could be monitoring/interacting with 30+ windows.
- I would like to achieve 3 fps+ in each window for any content that changes.