0

v7.palette to extract colors from images. now my problem is i am limited to only one swatch, and my question is how to get all the swatches allowing the palette to extract all the colors from the image and using that color .Please help N.B: Everything is working fine,Palette is working fine but with a small collection of colors

 public void updateColor(){


       final Bitmap bitmap = mImageFetcher.getArtwork(Utils.getAlbumName(),
               Utils.getCurrentAlbumId(), Utils.getArtistName());
       Palette palette = Palette.generate(bitmap);

       // Getting the different types of colors from the Image
       Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();







       // Adding the colors to the TextViews.

       if(vibrantSwatch!=null) {



           // Changing the background color of the toolbar to Vibrant Light Swatch
           toolbar.setBackgroundDrawable(new ColorDrawable(vibrantSwatch.getRgb()));

           if (Build.VERSION.SDK_INT >= 21) { //  setStatusBarColor only works above API 21!
               getWindow().setStatusBarColor(vibrantSwatch.getRgb());
           }
       }

   }

3 Answers3

0

Palettes intend is to extract the main colors not to give you a distribution of colors. You will have to look elsewhere for such a feature.

Moritz
  • 10,124
  • 7
  • 51
  • 61
  • I already knew that my question is how to extract all the swatches from the image (vibrant swatch,muted Swatch etc...)Thanks For Any Help – most unique Jun 25 '15 at 14:53
0

Check out Color Extractor (https://github.com/RacZo/ColorExtractor), it is a little app that I build as a proof of concept. It shows how to use the new Palette and Palette Builder classes to get colors and swatches from an image.

Oscar Salguero
  • 10,275
  • 5
  • 49
  • 48
0

Palette has a method getSwatches() which will return a list of Swatches.
(maybe this method did not exist when this question was asked)

David Artmann
  • 4,272
  • 1
  • 16
  • 24