捕获来自Android的看法位图 [英] capture bitmap from view android

查看:144
本文介绍了捕获来自Android的看法位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发布同样的问题,但它在接近我的问题,这就是为什么我已经发布了它第二次

I have posted same question but it's in near to my problem that's why i have posted it second time

您好我想从RelativeLayout的捕捉图像,对于我已经低于code使用

Hi i want to capture image from RelativeLayout, for that i have used below code

   captureRelativeLayout.setDrawingCacheEnabled(true);
   bitmap = captureRelativeLayout.getDrawingCache(true).copy(
                Config.ARGB_8888, false);

问题是,当我开始活动,并从这一观点当时得到的图像它会正常工作,但如果我用它第二次时,图像没有被刷新,意味着previous位图是每次我得到。

the problem is that when i start activity and get image from that view at that time it will work fine, but if i use it second time, the image is not being refreshed, means that previous bitmap is every time i getting.

现在,如果我收我的活动和agian启动它,然后我会得到更新的形象,但在第二次又没有
:(了解更多信息看
不能共享图像正常的Andr​​oid

Now if i close my activity and agian start it then i will get updated image but again not in second time :( for more information look at the can't share image properly android

推荐答案

您应该复制后销毁图纸缓存,因此缓存将再次下次呼叫 getDrawingCache()时建

You should destroy the drawing cache after copying it, so the cache will be built again next time you call getDrawingCache().

在code是这样的:

captureRelativeLayout.setDrawingCacheEnabled(true);
bitmap = captureRelativeLayout.getDrawingCache(true).copy(Config.ARGB_8888, false);
captureRelativeLayout.destroyDrawingCache();

或者这样,如果你不希望启用标志:

Or like this if you don't want to enable the flag:

captureRelativeLayout.buildDrawingCache(true);
bitmap = captureRelativeLayout.getDrawingCache(true).copy(Config.ARGB_8888, false);
captureRelativeLayout.destroyDrawingCache();

参考: https://groups.google.com/ D / MSG / Android的开发者/ IkRXuMtOA5w / zlP6SKlfX-0J

这篇关于捕获来自Android的看法位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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