在调色板中使用所有颜色样本

时间:2015-06-25 14:39:53

标签: android palette android-palette

v7.palette从图像中提取颜色。现在我的问题是我只限于一个色板,我的问题是如何让所有色板允许调色板从图像中提取所有颜色并使用该颜色。请帮助 N.B:一切都很好,Palette工作正常但颜色很少

 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 个答案:

答案 0 :(得分:0)

Palettes旨在提取主要颜色,而不是为您提供颜色分布。您将不得不在其他地方寻找这样的功能。

答案 1 :(得分:0)

查看Color Extractor(https://github.com/RacZo/ColorExtractor),它是我构建的一个小应用程序,作为概念验证。它展示了如何使用新的Palette和Palette Builder类从图像中获取颜色和色板。

答案 2 :(得分:0)

Palette有一个方法getSwatches(),它将返回一个Swatches列表 (当问到这个问题时,这种方法可能不存在)