LibGDX从base64 PNG ByteArrayInputStream创建纹理

Ike*_*suf 6 android textures bytearrayinputstream libgdx slick2d

我刚决定将Slick2D更改为LibGDX.但是,为了能够将我的游戏移植到LibGDX,我需要帮助了解如何从我的游戏数据文件中创建LibGDX中的纹理.

我的游戏数据文件是加密的,图像是用base64编码的,所以我可以将它们全部保存在一个txt文件中.如何从ByteArrayInputStream创建LibGDX纹理.

在Slick2D中,我将base64字符串转换为bufferedimage.但我不想为LibGDX这样做,因为我可能希望很快就能在Android上获得它.

编辑:我只是想通了,有点儿.我是这样做的:

   Texture bucket;
    String base64 = "base64 string too long to paste"
    byte[] decodedBytes = Base64Coder.decode(base64);
    bucket = new Texture(new Pixmap(decodedBytes, 0, decodedBytes.length));
Run Code Online (Sandbox Code Playgroud)

但是,现在图像垂直翻转......我错过了什么吗?

Ike*_*suf 2

Texture bucket;
String base64 = "base64 string too long to paste"
byte[] decodedBytes = Base64Coder.decode(base64);
bucket = new Texture(new Pixmap(decodedBytes, 0, decodedBytes.length));
Run Code Online (Sandbox Code Playgroud)

这对我有用。

它被翻转了,因为我将 OrthgraphicsCamera 更改为左上角有 0,0。