Sub GetPixels (img As Image) As Byte()
Dim jo As JavaObject = img
Dim reader As JavaObject = jo.RunMethod("getPixelReader", Null)
Dim buffer(img.Width * img.Height * 4) As Byte
Dim PixelFormat As JavaObject
PixelFormat.InitializeStatic("javafx.scene.image.PixelFormat")
Dim width = img.Width, height = img.Height As Int
reader.RunMethod("getPixels", Array(0, 0, width, height, PixelFormat.RunMethod("getByteBgraInstance", Null), _
buffer, 0, width * 4))
Return buffer
End Sub