I just decided to make the change from Slick2D to LibGDX. However, for me to be able to port my game over to LibGDX I need help understanding how to create textures in LibGDX from my game data files.
My game data files are encrypted and the images are encoded in base64 so I can keep them all in one txt file. How do I create a LibGDX texture from a ByteArrayInputStream.
In Slick2D I converted the base64 string into a bufferedimage. But I don't want to do that for LibGDX since I may want to get it on android soon.
EDIT: I just figured it out, kind of. I did it like so:
Texture bucket;
String base64 = "base64 string too long to paste"
byte[] decodedBytes = Base64Coder.decode(base64);
bucket = new Texture(new Pixmap(decodedBytes, 0, decodedBytes.length));
However, now the image is flipped vertically... Am I missing something?
Texture bucket;
String base64 = "base64 string too long to paste"
byte[] decodedBytes = Base64Coder.decode(base64);
bucket = new Texture(new Pixmap(decodedBytes, 0, decodedBytes.length));
That worked for me.
It was flipped because I changed the OrthgraphicsCamera to have 0,0 at the upper left.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With