The simplest way to decode a PNG from a stream is:
Bitmap png = new Bitmap(Image.FromStream(pngStream));
But this don't allow us to decode the PNG to an existing buffer. So if we use this way, Image.FromStream(..) has to allocate new memory for the image data every time we call it (and then GC has to collect the used memory every time too).
There is also PngBitmapDecoder, but it takes a Stream reference in constructors and decode the PNG inside constructors and has no other functions to do it, so i have to create new PngBitmapDecoder every time too.
So i want some ways to pass a reference/pointer to an existing byte buffer, so a PNG decoder use it every time, no redundant allocations/deallocations.
Is there other standard ways to do it or you can advise some 3rd-party libraries for .Net 4.6.2 to do this?