Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artefacts on texture with alpha channel #3

Open
sdelaysam opened this issue Jan 29, 2017 · 1 comment
Open

Artefacts on texture with alpha channel #3

sdelaysam opened this issue Jan 29, 2017 · 1 comment

Comments

@sdelaysam
Copy link

sdelaysam commented Jan 29, 2017

Hi, @longngo78

I have png image with transparency.
When using it as a texture I get the following (left is screenshot from device, right is the image itself)

artefacts

Default blending and bitmap config, nothing changed anywhere.
Here is the code :)

Texture texture = getTextureManager().createDrawableTexture(R.drawable.table, null);
Sprite table = new Sprite();
table.setTexture(texture);
addChild(table);

The same drawable in ImageView looks perfect.

EDIT:
Using BlendFunc.getPremultipliedAlpha() makes everything work. But why?

@longngo78
Copy link
Owner

Yes, I believe the way Android decodes PNG (w/ alpha) image is different. To fix this, the best way is to use BlendFunc.getPremultipliedAlpha() or BlendModes.PREMULTIPLIED_ALPHA_FUNC (they are the same).

You might consider to do texture.setFilters(GL10.GL_LINEAR, GL10.GL_LINEAR) for better render.
By default it uses GL10.GL_NEAREST which renders faster but is lower quality.

On a related note, if you're building a full application, extend or modify Pure2dApplication which allows to you config stuff including textures, fonts,... from a json file: ui_config.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants