android - How do i convert to Color to Bitmap? -


i have color in form of integer, , want color in bitmap form.
there way so?

i tried

drawable d = new colordrawable(color.parsecolor("#ffffff")); bitmap b = ((bitmapdrawable)d).getbitmap(); 

but above code give error cannot cast colordrawable bitmapdrawable

is there other way?

actual code is

palette.generateasync(bitmapfactory.decodefile(songart),             new palette.paletteasynclistener() {                 @override                 public void ongenerated(final palette palette) {                     if (build.version.sdk_int >= 16) {                         drawable colordrawable = new colordrawable(palette.getdarkvibrantcolor(                                 getresources().getcolor(r.color.noti_background)));                         notificationcompat.bigcontentview.setimageviewresource(r.id.noti_color_bg,                                 ((bitmapdrawable) colordrawable).getbitmap());                         notificationmanager.notify(notification_id, notificationcompat);                     }                 }             }     ); 

yes there is. this:

bitmap bmp=bitmap.createbitmap(width,height,config.argb_8888); canvas canvas=new canvas(bmp); canvas.drawcolor(colorint) 

inside drawcolor() can set color using methods of color class color.argb() or color.rgb()

that way have bitmap width, height , filled specified color.

further explanation: create bitmap specified dimensions. create canvas , attach bitmap it. way drawn using canvas methods gets drawn on bitmap.

in end have bitmap drawings in it


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -