Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

New Post: ToByteArray returns all zeros

$
0
0
I have the following code for a WinRT project:
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 function
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'?

Viewing all articles
Browse latest Browse all 360

Trending Articles