Android的:如何将整个的ImageView为位图? [英] Android: how to convert whole ImageView to Bitmap?

查看:143
本文介绍了Android的:如何将整个的ImageView为位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的应用程序,它与不同比例显示图像,调整内部(centerInside)ImageView的。我需要的是从ImageView的,包括背景(黑色在这种情况下)创建位图。

I have my application that is displaying images with different ratio, resized inside (centerInside) imageView. What I need is to create bitmap from the ImageView including the background (black in this case).

例如,我有设备屏幕小320x480,全屏幕的ImageView与图像调整到小280x480。我怎么能得到它小320x480位图?

So for example I have device screen 320x480, full screen imageView with image resized to 280x480. How could I get 320x480 bitmap from it?

在这个ImageView的我有一些标志或按钮,我不希望包括位图的顶部,他们就像在顶层。所有我需要的是位图与一些侧面图像和黑色边框。

On top of this imageview I have some logos or buttons that I don't want to include to bitmap, they're like on top layer. All I need is bitmap with image and black border from some sides.

推荐答案

您可以只使用的ImageView图像缓存。它将使整个视图,因为它奠定了(缩放,边框与背景等),以一个新的位图。

You could just use the imageView's image cache. It will render the entire view as it is layed out (scaled,bordered with a background etc) to a new bitmap.

只要确保它内置了。

imageView.buildDrawingCache();
Bitmap bmap = imageView.getDrawingCache();

有你的位图作为屏幕看到它。

there's your bitmap as the screen saw it.

这篇关于Android的:如何将整个的ImageView为位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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