1

I'm trying to read the bitmap pixel value in an android application. This project uses GDX framework which work with java.

I tried android.graphics.Bitmap import it doesn't exist in java then as the whole code is in the java project it's not possible.

Then I tried to use BufferedImage but it's not supported by android, also I don't know how to do.

0x6C38
  • 6,796
  • 4
  • 35
  • 47
Entretoize
  • 2,124
  • 3
  • 23
  • 44
  • You are confused between Android, Java and the SDK. `android.graphics.bitmap`, or any other class, does not "exist" in Java. What classes you have access to is only dependent on the SDK version your app is using. Java is Java no matter what SDK you use. The problem you have is that BufferedImage is not support in Android. http://stackoverflow.com/questions/5311163/how-to-load-bufferedimage-in-android – Simon Oct 13 '13 at 14:08

1 Answers1

0

In Libgdx the Pixmap is used to represent "in-CPU-memory" textures. (As opposed to the Texture objects which represent "in-GPU-memory" textures.) You can only manipulate pixels for texture data that is in CPU memory.

Libgdx supports loading Pixmap objects from JPG, PNG, and or BMP encoded files. Once loaded you can use the getPixel method to pixel values.

To actually display the Pixmap you have to upload the bitmap data to the GPU. In Libgdx that just means creating a Texture from the Pixmap.

P.T.
  • 24,557
  • 7
  • 64
  • 95
  • Thank you, I didn't find which function to use to open an image file to a pixmap, it's ok now: FileHandle file=Gdx.files.internal("data/myfile.png"); byte[] bytes = file.readBytes(); Gdx2DPixmap pixmap=null; pixmap = new Gdx2DPixmap(bytes, 0, bytes.length, 0); – Entretoize Oct 14 '13 at 17:26