I have a slow connection that I need to send a PNG image over (as a byte stream) and have the image be displayed immediately. I have a C# WinForms app accepting the byte[], loading it into a memory stream, and creating an System.Drawing.Image/Bitmap object from it.
What I would like to do is send a super low resolution image down, and then incrementally update it so that it gets clearer as the data is received. It looks like PNG supports interlaced images which do just what I want.
Is it possible to start showing the PNG before all the data is received and incrementally make it clearer as the rest of it comes in? How can I do this?
The interlaced option is pretty much obsolete today. It is to let someone with a slow internet connection like Dial-Up begin to see the picture quickly. An interlaced PNG displays an early degraded version of the whole image quickly, then displays the image correctly. Interlaced will be a bit bigger in filesize.
Interlaced image loads an early degraded version of the whole image as soon as possible and then progressively renders the image to clear state. Non-interlaced image will load up in tiles showing clear image in each tile as it progresses to load in the image.
Lots of image formats support interlacing, including GIF, JPEG, and PNG. Those three all do it differently. A bit of a terminology snafu here: JPEG calls its interlaced images "progressive JPEGs", which is a little bit confusing because in the video world, "progressive" explicitly means "non-interlaced".
You'd have to deliver the bytes in such a way that they conform to the Adam7 algorithm. Possibly a 3rd-party library could be Googled that delivers the bytes in such a way to take the hard work out of it.
Here's a visual example of what it would do.
Edit: LibPNG for Windows might be a start. Of course its DLL would require your .NET program to interact with unmanaged code and non-MSIL assemblies, and that's another story that I'm sure is posted elsewhere on stackoverflow - or maybe you could create another question for it in particular. LibPNG is an open source project so looking at its source code might provide insight on the Adam7 algorithm that could be recoded in C#/.NET.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With