I have the following code for a WinRT project:
However, The Bytes array contains all zeros. I need the byte array to store the image in my program's database. It obviously isn't working.
Is there something I'm not understanding about 'ToByteArray'?
Async Function SetImage(imagestream As IRandomAccessStream, image As Image) As Task
Dim Bitmap As New BitmapImage
Dim Bytes As Byte()
' Note
Bitmap.SetSource(imagestream) ' I get the width and height of the image from this
Dim Wbm as WriteableBitmap = New WriteableBitmap(Bitmap.PixelWidth, Bitmap.PixelHeight)
image.Source = Await Wbm.FromStream(imagestream)
Bytes = Wbm.ToByteArray
End Function
The image appears correctly on-screen after this functionHowever, The Bytes array contains all zeros. I need the byte array to store the image in my program's database. It obviously isn't working.
Is there something I'm not understanding about 'ToByteArray'?