0

Assume I have an image of red color ( mostly red inside image) then, how can I set the background according to that image file with a blur effect.

  • check this out : http://stackoverflow.com/questions/8471236/finding-the-dominant-color-of-an-image-in-an-android-drawable – Piyush Oct 19 '16 at 10:31

1 Answers1

0

You can use the Palette API to extract the prominent colors from bitmap images. Add the following dependency in gradle:

dependencies {
  compile 'com.android.support:palette-v7:23.1.1'
}

Create the palette object :

 Palette.PaletteAsyncListener paletteListener = new Palette.PaletteAsyncListener() {
  public void onGenerated(Palette palette) {
    // access palette colors here
  }
}

Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.nyancat);
if (myBitmap != null && !myBitmap.isRecycled()) {
    Palette.from(myBitmap).generate(paletteListener);
}

For more detailed process look here.

Frosty
  • 500
  • 4
  • 14