Programming with the jnigraphics library in Android NDK
The jnigraphics
library provides a C-based interface for native code to access the pixel buffers of Java bitmap objects, which is available as a stable native API on Android 2.2 system images and higher. This recipe discusses how to use the jnigraphics
library.
Getting ready…
Readers are expected to know how to create an Android NDK project. We can refer to the Writing a Hello NDK program recipe of Chapter 1, Hello NDK for detailed instructions.
How to do it...
The following steps describe how to create a simple Android application which demonstrates the usage of the jnigraphics
library:
Create an Android application named
JNIGraphics
. Set the package name ascookbook.chapter7.JNIGraphics
. Refer to the Loading native libraries and registering native methods recipe of Chapter 2, Java Native Interface for more detailed instructions.Right-click on the project JNIGraphics, select Android Tools | Add Native Support.
Add two Java files named
MainActivity...