Coder Social home page Coder Social logo

michaelevans / colorart Goto Github PK

View Code? Open in Web Editor NEW
899.0 49.0 140.0 3.62 MB

iTunes 11-style color matching code for Android

Home Page: http://www.michaelevans.org/blog/2013/12/12/colorart-a-library-to-do-itunes-11-style-color-matching-for-android/

License: Apache License 2.0

Java 100.00%

colorart's Introduction

##About

ColorArt is a library that uses an image to create a themed image/text display. It's a port of the idea found on the Panic Blog to work on Android.

##Usage

(ColorArt is supported on Android 2.1+.)

Add ColorArt as a dependency to your build.gradle file:

compile 'org.michaelevans.colorart:library:0.0.3'

Then you can use the library like this:

// get a bitmap and analyze it
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.album);
ColorArt colorArt = new ColorArt(bitmap);

// get the colors
colorArt.getBackgroundColor()
colorArt.getPrimaryColor()
colorArt.getSecondaryColor()
colorArt.getDetailColor()

###FadingImageView

mFadingImageView.setBackgroundColor(colorArt.getBackgroundColor(), FadingImageView.FadeSide.LEFT);

This will set the fading edge on the left side, with that background color. You can also enable/disable the fade with:

mImageView.setFadeEnabled(true/false);

##Screenshots

Jim Noir Ping Pong Orchestra Hotel Shampoo

##License

Copyright 2015 Michael Evans

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Bitdeli Badge

colorart's People

Contributors

michaelevans avatar nlefler avatar rndstr avatar xinghui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorart's Issues

add spaces between ### and titles

.. If you do so, your markdown starts to show up properly)
Cooooooool library! =)

Also, I'm interested, do you use some kind of random heuristics points or just scan the whole bitmap to calculate most dominant colors? (so that the algorithm complexity is O(n^2) ?)

Having problems getting correct colors.

It seems that the algorithm you're using has a tough time picking out reds. I'm using your library to pick out colors for albums and here is the first example of something going not as expected.

A Star Is Born

The background color is pretty good. It could be a little darker to reflect that the album background isn't pure white. My main issue is with the primary color here. There are pretty much only two colors on the album, white and red. The red doesn't show up in any of the colors, be it primary, secondary, or detail color. In all of these examples, the colors are as follows:

  • Background color is from ColorArt.getBackgroundColor()
  • Song title is ColorArt.getPrimaryColor()
  • Artist is ColorArt.getSecondaryColor()
  • The time played and time left textviews are ColorArt.getPrimaryColor()
  • The progress bar on the seekbar is ColorArt.getSecondaryColor()
  • The draggable thumb on the seekbar is ColorArt.getPrimaryColor()

Here's another example

11:11pm

The background color is a dark brown/green. Ideally it would be a red or a white as those are the two most dominant colors in the image and they also touch the borders.

Yet another example:

9MM

For this album cover, the background color is good. What's weird is that the primary color is pink. There isn't really pink on the album cover, though there is a bit of red in the reflection of the sunglasses. It would make more sense for the primary color to be a black, white or brown.

Moar example:

Say Something

There should be red/magenta as the primary color.

Last example:

Witness

Nix the purple/lilac. Use the reds/oranges/light blues/blacks or whites. The background color should definitely be white here as that is also the background color of the album. Red or orange would work as well.

EDIT:

I found some more weird occurrences. In the following image, there shouldn't be any light blue.

More to Life

In the following image, there should not be pink.

Yiruma

In the future, similar to Chris Banes's ColorFinder, it would be nice to have a secondary text color which is either black or white depending on the brightness of the background color to ensure high visibility/readability.

NullPointerException in findTextColors()

I could trigger an NPE in findTextColors(), line 164

            } else if (mSecondaryColor == null) {
NPE HERE  =>   if (!isDistinctColor(mPrimaryColor, currentColor) ||        
                        !isContrastingColor(currentColor, mBackgroundColor)) {
                    continue;

mPrimaryColor can be null, hence the NPE since isDistinctColor() expects an int as first parameter.

remove android:allowBackup

Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:28:9-36
is also present at [org.michaelevans.colorart:library:0.0.3] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to element at AndroidManifest.xml:23:5-58:19 to override.

Crashes when working with images that has transparent pixels

java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.ComparableTimSort.mergeLo(ComparableTimSort.java:710)
at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:447)
at java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:372)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:178)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:142)
at java.util.Arrays.sort(Arrays.java:1973)
at java.util.Collections.sort(Collections.java:1867)
at org.michaelevans.colorart.library.ColorArt.findTextColors(ColorArt.java:154)
at org.michaelevans.colorart.library.ColorArt.analyzeImage(ColorArt.java:49)
at org.michaelevans.colorart.library.ColorArt.(ColorArt.java:44)

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.