Posts

Showing posts with the label Android Programming Tutorial

How to use Palette API to extract colors from Image or Vector drawable Image Fully detailed tutorial

Image
The usages example of Palette API - Android Studio Hello Guys, Today I going to share an amazing tutorial on Palette API, The API is very easy to implement and has many useful features, but today I going to share the only the process of how we can use Palette to get Color from regular Image, Or from vector drawbles. The old constructor instances: Bitmap bmp; //(Keep In mind that, You need decode the bitmap or vector first to get its color from palette, and this is just an example) Palette palette = Palette.generate(bmp); is deprecated from android API 29, So app target SDK 29 or Minimum SDK 29 we need an alternative version of this constructor. Don't worry, I am here to help! The Palette.generate(Bitmap) deprecated,The alternative code is here! Now time to write the right code for palette.generate(Bitmap) & for color extraction The Code: //Starts the code from here! //decode the bitmap so that palette can use this bitmap