Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Processing bitmaps natively


The Android NDK proposes an API dedicated to bitmap processing, which gives direct access to the surface of Android bitmaps. This API is specific to Android and is not related to the JNI specification. However, bitmaps are Java objects and will need to be treated as such in native code.

To see more concretely how bitmaps can be modified from native code, let's try to decode a camera feed from native code. Raw video frames recorded on Android are generally encoded in a specific format, YUV, which is not compatible with classic RGB images. This is a situation where native code comes to the rescue to help us decode such images. In the following example, we are going to extract each color component (that is, red, green, and blue) into a separate bitmap.

Note

The resulting project is provided with this book under the name LiveCamera.