I was checking the MS library.
and it looks like PixelBuffer.AsStream()
is obsolete for the Universal App development.
I'm using Win10(build 10240) with VS2015 Community version.
Do I miss anything ?
Additionally, what's the best way to encode or write a stream into the WriteableBitmap from the bytes or integers array?
I was trying the method from the BitmapEncoder, but I could create it only this way:
BitmapEncoder enc = await BitmapEncoder.CreateForTranscodingAsync(fileStream, decoder);
enc.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, W, H, 200, 200, sourcePixels);
and afterwards there was no modifications visible on the WriteableBitmap. otherwise the framework was throwing exceptions(outside of my code)
Decoder was working fine and I've get all pixels properly decoded and streamed to byte[] sourcePixels array.
AsStream is not obsolete. It is valid as shown in the linked MSDN sample code. It is an extension method to make IBuffer management easier not directly a mother on IBuffer. See https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.windowsruntime.windowsruntimebufferextensions.asstream(v=vs.110).aspx
To use it put the following using at the top of the source file:
Then you'll be able to call PixelBuffer.AsStream as shown in the documentation's sample: