From a fragment, I am trying to extract some colors from an image using the Palette class:
Bitmap snap = BitmapFactory.decodeResource(getActivity().getResources(),
R.drawable.snapghostyellow);
Palette palette = Palette.generate(snap);
Palette.Swatch vibrant = palette.getVibrantSwatch();
if(vibrant != null) {
Log.d("rgb_output", "vibrant Not Null " + Integer.toString(vibrant.getRgb()));
}
However the return of getRgb()
is in this case -1024
. The problem also occurs with other swatches (e.g. getDarkVibrantSwatch).
Trying to use the outputs crashes the app.
Any suggestions to what is wrong?