Use Pngquant Lib (libimagequant) In Android Ndk
Solution 1:
I don't have enough information to directly solve your specific problem, are you trying to use the standalone toolchain ?
When building for Android, since you have more than one architecture to target and the toolchain is a bit complex, it's better to use the ndk-build script from the NDK.
I've made a project here that you can integrate to your Android project directory: https://github.com/android-native-libraries/pngquant-android
The original library is using configure script but instead of extending these I've rewritten NDK Makefiles to directly compile all the lib sources, with the same cflags (openmp, sse...)
Android.mk:
LOCAL_PATH := $(call my-dir)
SRC_PATH := pngquant/lib
include$(CLEAR_VARS)
LOCAL_MODULE := imagequant
LOCAL_SRC_FILES := \
$(SRC_PATH)/blur.c \
$(SRC_PATH)/libimagequant.c \
$(SRC_PATH)/mediancut.c \
$(SRC_PATH)/mempool.c \
$(SRC_PATH)/nearest.c \
$(SRC_PATH)/pam.c \
$(SRC_PATH)/viter.c
LOCAL_C_INCLUDES := pngquant/lib
LOCAL_CFLAGS += -O3 -fno-math-errno -funroll-loops -fomit-frame-pointer -Wall -std=c99 -fopenmp
LOCAL_LDFLAGS += -fopenmp
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -mtune=atom -msse -mfpmath=sse -mssse3 -DUSE_SSE=1
endifinclude$(BUILD_SHARED_LIBRARY)
You can extend this Android.mk file to add your own native library with your sources, that are using libimagequant: include $(CLEAR_VARS) LOCAL_MODULE := yourlib LOCAL_SRC_FILES := yoursources.c LOCAL_C_INCLUDES := pngquant/lib LOCAL_SHARED_LIBRARIES := imagequant
LOCAL_CFLAGS += -O3 -fno-math-errno -funroll-loops -fomit-frame-pointer -Wall -std=c99 -fopenmp
LOCAL_LDFLAGS += -fopenmp
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -mtune=atom -msse -mfpmath=sse -mssse3 -DUSE_SSE=1
endifinclude$(BUILD_SHARED_LIBRARY)
Solution 2:
If you just want to use this library with default settings, I've made a simple Android library that may suit your purposes.
In your build.gradle:
dependencies {
compile'com.ndahlquist:pngquant-android:0.2'
}
In your Android app:
FileinputPngFile= getYourPng();
FileoutputPngFile= getOutputFile()
newLibPngQuant().pngQuantFile(inputFile, outputFile);
Post a Comment for "Use Pngquant Lib (libimagequant) In Android Ndk"