I would like to overlay two images in a texture in libgdx dynamically. I tried to create two pixmap and then draw them into a texture. The problem is that the region of the transparent png on the highest level delete the picture in the background. In the example, the white part of PNG2 is transparent and so is the white part of the image RESULT.

enter image description here

My code is:

Pixmap imgA = new Pixmap(Gdx.files.internal(back));
Pixmap imgB = new Pixmap(Gdx.files.internal(overlay));             

Texture dynamicTexture = new Texture(200, 200, Pixmap.Format.RGBA8888); 
dynamicTexture.draw(imgA, 0, 0);           
dynamicTexture.draw(imgB, 27, 27);
有帮助吗?

解决方案

Try drawing the smaller pixmap to the biggest one, and then to the Texture:

Pixmap imgA = new Pixmap(Gdx.files.internal(back));
Pixmap imgB = new Pixmap(Gdx.files.internal(overlay));             
Texture dynamicTexture = new Texture(200, 200, Pixmap.Format.RGBA8888);
imgA.draw(imgB, 27, 27);
dynamicTexture.draw(imgA, 0, 0);

Reference: this other question

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top