Borr
Borr

Reputation: 33

How to create Image file in libGDX from pixel array

I stuck in one point where I have to create image file(the best would be PNG) from pixel array where the array, width and height are given as parameters. The real problem is that i can't use BufferedImage or ImageIO.

Implementation of this is already implemented in Android subproject using Bitmap like this:

Bitmap bitmap = Bitmap.createBitmap(pixels,
                width, height, Bitmap.Config.ARGB_8888);

Pixel map is created by merging 3 images color informations.

Without using BufferedImage or ImageIO I have no idea how to deal with it.

Do u have any ideas how to achieve that?

Upvotes: 1

Views: 413

Answers (1)

icarumbas
icarumbas

Reputation: 1815

Use Pixmap:

Pixmap pixmap = new Pixmap(pixels, 0, pixels.length);
Texture texture = new Texture(pixmap); 

Upvotes: 1

Related Questions