How to convert array of pixels int[] to WriteableBitmap in Windows Phone 8? Later on I'd like to save this image to MediaLibrary.
2 Answers
The only way I know on Windows Phone is using the WriteableBitmapEx library. In addition to WriteableBitmap it implements an "SetPixel method with various overloads":
http://writeablebitmapex.codeplex.com/
The Library can simply be installed from within Visual Studio 2012:
PROJECT => Manage NuGet Packages => Online => Search for "WriteableBitmapEx"
Comments
You may use copyTo member function of int[] for copying int[] to WriteableBitmap.
int[] ARGBPx = new int[(int)captureDevice.PreviewResolution.Width * (int)captureDevice.PreviewResolution.Height];
WriteableBitmap writeableBitmap_preview;
ARGBPx.CopyTo(writeableBitmap_preview.Pixels, 0);
writeableBitmap_preview.Invalidate();
System.InvalidOperationException, I was told it is because of incorrectly created WriteableBitmap.