1

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);
Daahrien
  • 10,190
  • 6
  • 39
  • 71
user1169390
  • 151
  • 11
  • is the white part in png2 actually transparent or is it just white? Try creating a batch and have it draw the images consecutively – Tom S. Nov 20 '13 at 09:42
  • The white part in png2 is transparent. I don't use a batch because I put this composite image in a ScrollPane. – user1169390 Nov 20 '13 at 09:58

1 Answers1

1

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

Community
  • 1
  • 1
Daahrien
  • 10,190
  • 6
  • 39
  • 71