Skip to content

FlashLight13/poliwhirl

Repository files navigation

Android Arsenal Actual version API

Poliwhirl

Description

This is a small image processing library done to find good color for icon background. It uses CIEDE2000 to determine what colors can be processed as the same.

Result example

Here goes the table with the generated colors.

Input Result

Usage

Gradle:

compile 'com.antonpotapov:poliwhirl:$version'

Maven:
<dependency>
    <groupId>com.antonpotapov</groupId>
    <artifactId>poliwhirl</artifactId>
    <version>$version</version>
</dependency>
In code:

You need to use only one class: Poliwhirl(). It's instance is reusable. So, you may create in only once. Also, there is no any long-time operations in instance creation, so you can create it each time you need it.

Async way
Poliwhirl().generateAsync(bitmap, object : Poliwhirl.Callback {
    override fun foundColor(color: Int) {
      // do whatever you need with the color
    }
})
Sync way

Poliwhirl().generate(bitmap);

Customizable way

Here you can provide an executor to poliwhirl. Poliwirl will try to execute it's calculation in parallel in this case. Also you can provide something like current-thread executor (thats how sync way is done) or whatever you need.

Poliwhirl().generateOnExecutor(bitmap, object : Poliwhirl.Callback {
    override fun foundColor(color: Int) {
        pictureBackground.setBackgroundColor(color)
    }
}, Executors.newSingleThreadExecutor())