In a flow of pictures, I’m looking for a way to send only their differences rather than the whole pictures, to lower transmission size and time (unless, of course, if the only existing ways take significant longer than sending the whole pictures).
I believe apps like Remote Desktop do that: find differences between two frames and only send the relevant changes over the network.
For now, I have this test code:
dim p1 as Picture=Picture.Open(SpecialFolder.Desktop.Child("c1.png"))
dim p2 as Picture=Picture.Open(SpecialFolder.Desktop.Child("c2.png"))
dim p3 as Picture=DiffPicturesMBS(p1,p2,True)
c1.png and c2.png are screenshots I’ve taken with slight differences (seconds on the clock and one window’s content).
This produces a picture where all pixels that are equal are black; so far, so good, now I have to send the areas of the original picture (p2 in my example above) that are not black in p3.
But if I have to loop through p3 to check every non-black pixel, it won’t be faster than manually comparing every pixel between p1 and p2. Timing is my issue here.
Ideally, I’d like to get rectangles around non-black pixels so I can extract the coordinates and report them on p2 to send its changes, but I recognise “packaging” pixels in best-arranged rectangles is going to be hard.
Otherwise, I guess I could be satisfied by encoding each pixel (x, y and colour) and sending them in one message.
Whichever path I choose, I fail to see how to encode these pixels; that is, knowing fast their x,y position (and then, their colour) without looping through all the pixels for every picture, which would be too slow.
I’m sure this is not built into Xojo, but I’m wondering:
• can the MBS plugin do that? (based on my searches, I’d think the answer is “no”)
• is it actually a waste of time trying to improve how I transmit my pictures and I have no other choice than sending them entirely each time?
• any other thoughts?
In the real project, pictures (screenshots) are taken in a loop, so this makes a lot of them.