1

How to convert array of pixels int[] to WriteableBitmap in Windows Phone 8? Later on I'd like to save this image to MediaLibrary.

3
  • 1
    Did you tried anything? Show your effort first.. Please read FAQ and How to Ask Commented Mar 17, 2013 at 9:03
  • I am trying since yesterday... Ok I can create WriteableBitmap, but later I can't save it using MediaLibrary, I get System.InvalidOperationException, I was told it is because of incorrectly created WriteableBitmap. Commented Mar 17, 2013 at 9:13
  • What have you tried? Show exactly what you're doing. How are you trying to save it? What operation causes the exception? To get good answers you need to write good questions. See tinyurl.com/so-hints Commented Mar 17, 2013 at 12:39

2 Answers 2

1

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"

Sign up to request clarification or add additional context in comments.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.