我怎样才能得到我得到的OnDraw画布的位图? [英] How can I get the bitmap of the canvas I get in onDraw?

查看:156
本文介绍了我怎样才能得到我得到的OnDraw画布的位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以创建自定义视图画布的位图。

How can I create the bitmap from the canvas of custom view.

推荐答案

有没有办法提取位图帆布<的/ code>。您可以访问它的唯一方法是创建这样的画布,当自己把它传递新的Canvas(MYBITMAP)并保持基准。

There is no way to extract the Bitmap out of a Canvas. The only way you can access it is to pass it yourself when creating the canvas like this new Canvas(myBitmap) and keep the reference.

EDIT2:看@Alex评论的打击 - 传递的方式一位图画布似乎并不对于Android的较新版本。

see @Alex comment blow - the approach of passing a Bitmap to the Canvas does not seem to work for more recent versions of Android.

编辑:如果你没有创建画布你自己,你可以创建一个屏幕大小的位图(或者你需要的任何大小),然后将其传递给画布的OnDraw 要求是这样的: canvas.setBitmap(MYBITMAP)

EDIT : If you don't create the Canvas yourself, you could create a screen-sized Bitmap (or whatever size you need) and then pass it to the Canvas in onDraw calls like this: canvas.setBitmap(myBitmap).

这篇关于我怎样才能得到我得到的OnDraw画布的位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆