Solved libGDX get pixels out off TextureRegion


      here it is 8 pixels
      System.out.println(chunk.getRegionWidth());
		
		Texture texture = chunk.getTexture();
		
		System.out.println(texture.getWidth());
      here it is back to 80 pixels

		
		texture.getTextureData().prepare();
		map = texture.getTextureData().consumePixmap();

if i do that it takes the pixels out off the orginal image and not the cutted texture region

What’s the problem exactly?

basicly i random generate an image 80x80 pixels
then i cut this image down to 8x8 images and pass on to my chunk system
all chunks needs to be able to ready this 8x8 image and get there pixel but the only way i know to get pixels is by doing this

	
		TextureRegion chunk... <-- the 8x8 image

		Texture texture = chunk.getTexture();
		
		texture.getTextureData().prepare();
		map = texture.getTextureData().consumePixmap();

and what this does

 chunk.getTexture();

it goes back to the orginal image of 80x80 pixels and no chunk is getting the blocks its suppose 2

A TextureRegion is merely just a region of a texture. It doesn’t make a new texture, it just has numbers telling what part of the texture it occupies. You can use the TextureRegion’s bounds to get the desired pixel on the original Texture object.

Say your region is using pixels from 8, 8 to 16, 16. If you want to get the pixel at 1, 1 in your region, you would start at where the texture region starts ( 8, 8 ) and add your desired coordinates that are in your region (1, 1). That ends up to the pixel at 9, 9 on your texture.

thanks mate :slight_smile: really help alot =D now i know what texture region does better as well