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.
Here goes the table with the generated colors.
Input | Result |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
compile 'com.antonpotapov:poliwhirl:$version'
<dependency>
<groupId>com.antonpotapov</groupId>
<artifactId>poliwhirl</artifactId>
<version>$version</version>
</dependency>
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.
Poliwhirl().generateAsync(bitmap, object : Poliwhirl.Callback {
override fun foundColor(color: Int) {
// do whatever you need with the color
}
})
Poliwhirl().generate(bitmap);
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())