KA
kamalkishor1991/croma
Library for getting useful colors from an image.
Croma
Lib for getting useful colors from an image.
Release
Croma is now avialable at jcenter.
Gradle
implementation 'org.numixproject.colorextractor:colorextractor:1.4'
Maven
<dependency>
<groupId>org.numixproject.colorextractor</groupId>
<artifactId>colorextractor</artifactId>
<version>1.4</version>
<type>pom</type>
</dependency>
v1.0
v1.1
- Bug fixes
- New ColorPicker implementation based on Median Cut
v1.2
- New distance calculation based on LAB color space.
v1.3
- Final filtering based on HSL color space.
v1.4
- Fixed a bug in LAB to RGB conversion
- Added new methods to convert RGB to LAB in Color class
- DBScanColorPicker is now deprecated
Usage
This library can be used for both android and desktop systems.
You just need to extend Image differently in both.
Here is one example of how It can be Implemented in android:
public class BitmapImage extends Image {
private Bitmap image;
public BitmapImage(Bitmap b) {
super(b.getWidth(), b.getHeight());
this.image = b;
}
public BitmapImage(File f) {
this(BitMapImage.create(f));
}
private static Bitmap create(File f) {
Bitmap image;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
image = BitmapFactory.decodeFile(f.getAbsolutePath(), options);
return image;
}
@Override
public Color getColor(int x, int y) {
return new Color(image.getPixel(x, y));
}
@Override
public Image getScaledInstance(int width, int height) {
Bitmap resized = Bitmap.createScaledBitmap(this.image, width , height, true);
return new BitMapImage(resized);
}
}Desktop Implementation using awt package
License:
Croma is licensed under MIT. For more information see https://opensource.org/licenses/MIT
On this page
Latest Release
v1.1September 15, 2014MIT License
Created July 29, 2014
Updated January 14, 2023