jeffreyliu8/Native-Floyd-Steinberg-Dithering


Android library for native floyd steinberg dithering on bitmap

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.jeffreyliu8:native-floyd-steinberg-dithering:1.1.5'
	}
	dependencies {
		implementation("com.github.jeffreyliu8:native-floyd-steinberg-dithering:1.1.5")
	}
	<dependency>
	    <groupId>com.github.jeffreyliu8</groupId>
	    <artifactId>native-floyd-steinberg-dithering</artifactId>
	    <version>1.1.5</version>
	</dependency>

                            
    libraryDependencies += "com.github.jeffreyliu8" % "native-floyd-steinberg-dithering" % "1.1.5"
        
        

                            
    :dependencies [[com.github.jeffreyliu8/native-floyd-steinberg-dithering "1.1.5"]]
        
        

Readme


License

Native-Floyd-Steinberg-Dithering

Android library for floyd-steinberg dithering on bitmap using JNI/Cmake

Why FSD

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(see below) would still look bad, this is when this algorithm and library is usful.

I have tried using just java to run the algorithm, but it is slow. This library is small and easy to use. Ideally you should NOT run this not on the main thread.

Using FSD

Setup

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
Dependencies
	dependencies {
		implementation 'com.github.jeffreyliu8.Native-Floyd-Steinberg-Dithering:release:1.1.5'
	}

The last working version is compile 'com.github.jeffreyliu8.Native-Floyd-Steinberg-Dithering:release:1.1.3'.

A quick example is shown below:

val original = BitmapFactory.decodeResource(resources, R.drawable.lena)
val fsBitmap = Utils().floydSteinbergDithering(original)

And for just black and white image:

val bwBitmap = Utils().binaryBlackAndWhite(original)

And for gray-scale image(This is just a simple java function):

val grayBitmap = Utils().toGrayscale(original)

Output sample

Requirements

Requires a minimum SDK version of 16 (14 should still work)