1
using (MemoryStream ms = new MemoryStream())
{
    image.CreateOptions = BitmapCreateOptions.None;
    image.UriSource = new Uri("/Images/chef.png", UriKind.Relative);              

    WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
    LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight,0,95);
    ms.Seek(0, 0);
    byte[] data = new byte[ms.Length];
    ms.Read(data, 0, data.Length);
    ms.Close();
 }

I am getting NullReferenceException at image, but my path is also correct and image also exists.

WriteableBitmap LoadedPhoto = new WriteableBitmap(image);

Is anything goes wrong.

4
  • 2
    I don't see the line BitmapImage image = new BitmapImage() or anything similar? Commented Sep 16, 2013 at 12:21
  • Please Refer this solution first, stackoverflow.com/questions/4732807/… Commented Sep 16, 2013 at 12:26
  • are you getting your solution or yet not? Commented Sep 23, 2013 at 11:00
  • Where do you create the image object? Commented Sep 25, 2013 at 8:58

1 Answer 1

0

Please Refer the solution. which shows the solution to converting the bitmapimages to byte array.

I hope you will understand.. conversion of bitmapimage to byte array

Refer this link..

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

1 Comment

Thanks...but now I am getting UnauthorisedException.

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.