libGDX: treat first color in palette as transparent color
Asked Answered
M

1

6

old game engines designate the first color of an image's palette as a transparent color. is there a way to do the same with libGDX?

i tried loading the picture and replacing the palete's first color with 0x00000000. however since the pixels are either opaque or transparent i dont need alpha values so i could save a lot of memory by using RGB888 instead of RGBA8888. i lookes through the gdx and opengl documentary for other blending options and found Gdx.gl20.glBlendColor and the SpriteBatch's setBlendFunction function. but they only change the values used in the blending equations.

thanks in advance :)

Madelainemadeleine answered 9/4, 2012 at 20:35 Comment(1)
I don't know of a way to do that, and I'm not really sure why you need to. I think most graphics surfaces are 32-bit, so even if you load 24-bit images, it will just be converted. It's probably best to just use RGBA8888 unless you're actually running out of memory.Paolo
T
3

to draw a textureRegion transparently use the routine like this:

    Color c = batch.getColor();
    batch.setColor(1, 1, 1, alpha);
    batch.draw(....);
    batch.setColor(c);
Timms answered 28/4, 2012 at 8:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.