While highly unlikely, in some experiments you might come to a situation where you want to initialize a LibGDX texture object, with an android bitmap you currently have in memory.
Here's how:
Here's how:
B4X:
Sub BitmapToTexture(image As Bitmap, texture As lgTexture) As Boolean
Dim pixmap As lgPixmap
Dim out As OutputStream
out.InitializeToBytesArray(0)
image.WriteToStream(out, 100, "PNG")
out.Close
pixmap.InitializeWithArray(out.ToBytesArray, 0, out.ToBytesArray.Length)
If texture.IsInitialized Then texture.dispose
Try
texture.InitializeWithPixmap(pixmap)
pixmap.dispose
Return True
Catch
pixmap.dispose
Return False
End Try
End Sub
Last edited: