How can I start showing interlaced PNG before all the data is received?

I have a slow connection that I need to send a PNG image (as a stream of bytes) and display the image right away. I have a C # WinForms application that takes a byte [], loads it into a memory stream and creates a System.Drawing.Image / Bitmap object from it.

What I would like to do is send the high-resolution image down, and then incrementally update it so that it becomes more understandable as the data is received. PNG seems to support interlaced images that do exactly what I want.

Is it possible to start showing PNG before all the data is received and gradually becomes clearer when the rest is included? How can i do this?

+6
c # winforms gdi +
source share
1 answer

You will need to deliver the bytes in such a way that they match the Adam7 algorithm. Perhaps a third-party library could be Googled, which supplies the bytes in such a way as to get the hard work out of it.

Here is a visual example of what he will do.

Edit : LibPNG for Windows could be the beginning . Of course, its DLL will require your .NET program to interact with unmanaged codes and non-MSIL assemblies, and this is another story, which I'm sure is located elsewhere in stackoverflow - or perhaps you could ask for it one more question. LibPNG is an open source project, so its source code can give an idea of ​​the Adam7 algorithm, which can be transcoded into C # /. NET

+2
source share

All Articles