Search code examples
androidcanvasdrawable

how to change canvas with Drawable?


I need to convert the rotated canvas image to drawable.

Conversely, there are many ways to convert from drawable to canvas, but I could not find what I wanted.

Is it not common to convert from Canvas to Drawable?

Should I use another method?

Please let me know, Thank you.


Solution

  • View v = new View(this);
    v.setDrawingCacheEnabled(true);
    v.draw(canvas);
    Bitmap b = v.getDrawingCache();
    Drawable drawable = new BitmapDrawable(getResources(), b);