Android的:如何将整个的ImageView为位图?位图、如何将、Android、ImageView

2023-09-12 02:48:55 作者:蛰伏半世情

我有我的应用程序,它与不同比例显示图像,调整内部(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.