Public Sub BitmapToByte (SourceBitmap As Bitmap) As Byte()
Dim mBuffer() As Byte
Dim jo As JavaObject = SourceBitmap
Dim format As Object = jo.RunMethod("getConfig", Null)
If "ARGB_8888" <> format Then
Log("Unsupported format: " & format)
Return
End If
Dim bf As JavaObject
bf = bf.InitializeStatic("java.nio.ByteBuffer").RunMethodJO("wrap", Array(mBuffer))
jo.RunMethod("copyPixelsToBuffer", Array(bf))
Return mBuffer
End Sub