How to get the current canvas bitmap?

I want to get the current bitmap associated with my canvas so that I can perform operations on it. I can’t figure out how to do this.

I saw some examples where you create a bitmap and set the canvas to use this bitmap, so obviously you can access it later, but I use the canvas returned from SurfaceHolder, so there is no constructor.

For example, examples often show such things:

Bitmap bmp = Bitmap.createBitmap(xxx, yyy, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmp);
  • so at this moment i see bmp.

In my case, the canvas is:

final SurfaceHolder holder = getSurfaceHolder();

    Canvas c = null;
    try {
        c = holder.lockCanvas();

So how can I get a bitmap for c?

@Reuben - , , . , , , "", , , . . , , , , - , . , , !

+3
2

, :)

BitmapDrawable bitDrawable = new BitmapDrawable();
bitmapDrawable.draw(videoView.getHolder().lockCanvas());

BitmapDrawable.

:

imageView.setImageBitmap(bitmapDrawable.getBitmap());

+3

c.getSurface() Surface.

0

Source: https://habr.com/ru/post/1775167/


All Articles