0
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.

anderZubi
  • 6,414
  • 5
  • 37
  • 67

1 Answers1

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..

Community
  • 1
  • 1
Nikhil Prajapati
  • 944
  • 1
  • 12
  • 30