I was able to create + use OpenJPEG to upload JPEG2000 images to my application using the following outline. You will have to customize it to suit your environment and how you want to use it. My answer contains rough recommendations along with specific answers to the main stumbling blocks that I encountered (which should be Android.mk and Application.mk files, as well as how to deal with the fact that the OpenJPEG library requires cmake).
Since we're talking about OpenJPEG, this answer assumes that you are familiar and plan to use the Android NDK for your application. It is also assumed that you are using the Eclipse version of the Android IDE. The answer also assumes that you are familiar with how static libraries work with Android NDK and how to reference them in the main application. You can expand my answer below to create a shared library or include code directly in your application. If you are not familiar with these premises, stackoverflow and Google can help.
I succeeded Android NDK r8e and OpenJPEG 2.0.0.
Steps:
- Download and open OpenJPEG 2.0.0 from http://www.openjpeg.org/index.php?menu=download
- Create your own project in Eclipse. I created a project that allows me to use OpenJPEG as a static library.
- In the jni folder of my project, I used the following for my Application.mk and my Android.mk files. See below.
- Create a custom opj_config.h. OpenJPEG is designed to be compiled using cmake. I did not want to deal with this for a number of reasons: none of my other materials relies on it (so it will add another level of complexity), I am on Windows (which has no built-in, and this postoverflow post is referenced by android-cmake , docs for android-cmake indicate that it may not work on Windows). See below my opj_config.h. This should work for you. Make sure you put it somewhere in your inclusion paths.
- Create an Android NDK Static Library Project
- Link to your static library in your main project
With this, I was able to successfully upload the JPEG2000 image to my Android NDK-based application.
Application.mk:
APP_ABI := all APP_PLATFORM := android-9 APP_MODULES := openjpeg
Android.mk (you will need to configure all the paths below):
# Taken from https://stackoverflow.com/questions/4036191/sources-from-subdirectories-in-makefile
opj_config.h (usually cmake creates this for the platform for which you are building, but, as I mentioned above, I did not want to deal with cmake, so I manually created this file):
#ifndef OPJ_CONFIG_H #define OPJ_CONFIG_H #define OPJ_PACKAGE_VERSION "2.0.0" #define HAVE_INTTYPES_H 1 #define HAVE_MEMORY_H 1 #define HAVE_STDINT_H 1 #ifndef HAVE_STDLIB_H
source share