Conversion of BitmapImage to Byte array

前端 未结 3 843
悲哀的现实
悲哀的现实 2020-11-30 13:55

I want to convert a BitmapImage to ByteArray in a Windows Phone 7 Application. So I tried this but it throws the runtime Exception \"Invalid Pointer Exception\". Can anyone

3条回答
  •  無奈伤痛
    2020-11-30 14:11

    I had same problem, this solves it:

    Code before:

    BitmapImage bi = new BitmapImage();
    bi.SetSource(e.ChosenPhoto);
    WriteableBitmap wb = new WriteableBitmap(bi);
    

    Code after:

    BitmapImage bi = new BitmapImage();
    bi.CreateOptions = BitmapCreateOptions.None;
    bi.SetSource(e.ChosenPhoto);
    WriteableBitmap wb = new WriteableBitmap(bi);
    

提交回复
热议问题