GithubHelp home page GithubHelp logo

kamalkishor1991 / croma Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 5.0 24.21 MB

Library for getting useful colors from an image.

Home Page: https://play.google.com/store/apps/details?id=app.croma

License: MIT License

Java 100.00%
java croma android java-library color-extraction

croma's Introduction

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

Download jar

v1.1

Download jar

  1. Bug fixes
  2. New ColorPicker implementation based on Median Cut

v1.2

Download jar

  1. New distance calculation based on LAB color space.

v1.3

Download jar

  1. Final filtering based on HSL color space.

v1.4

Download jar

  1. Fixed a bug in LAB to RGB conversion
  2. Added new methods to convert RGB to LAB in Color class
  3. 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

AWTImage.java

License:

Croma is licensed under MIT. For more information see https://opensource.org/licenses/MIT

croma's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

croma's Issues

My app crashes when trying to use DBScanColorPicker

Hi. Thanks for this amazing library.

It works great, but I'm having a little issue. It crashes my app if I try to use DBScanColorPicker. It works great with the other two algorithms.

Here is my code if it matters,

private String getColors(Bitmap bitmap) {
    String url = INDEX + "#/palette/show?palette=";

    BitMapImage b = new BitMapImage(bitmap);

    DBScanColorPicker k = new DBScanColorPicker();

    try {
        List<Color> l = k.getUsefulColors(b, 6);

        for (Color c : l) {
            url += c.getRed() + "," + c.getGreen() + "," + c.getBlue() + "|";
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return url;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.