Android library for floyd-steinberg dithering on bitmap using JNI/Cmake
For those who don't know the purpose of Floyd-Steinberg algorithm, it is a algorithm to turn color image to black and white(NOT GRAYSCALE).
When would we use this? Well, for those e-ink displays like Amazon Kindle, they can't display color images, and just black and white would still look bad, this is when this algorithm is usful.
I have tried using just java to run the algorithm, but it is slow. Not a good idea to run on main thread. This library is small and easy to use.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
} dependencies {
compile 'com.github.jeffreyliu8:Native-Floyd-Steinberg-Dithering:0.0.5'
}A quick example is shown below:
Bitmap original = BitmapFactory.decodeResource(getResources(), R.drawable.lena);
Bitmap fsBitmap = Utils.floydSteinbergDithering(original);And for just black and white image:
Bitmap bwBitmap = com.askjeffreyliu.floydsteinbergdithering.Utils.binaryBlackAndWhite(original);And for gray-scale image(This is just a simple java function):
Bitmap grayBitmap = com.askjeffreyliu.floydsteinbergdithering.Utils.toGrayscale(original);Requires a minimum SDK version of 14
