Android的:如何从缩放图像停止的Andr​​oid 1.6+缩放、图像、Android、oid

2023-09-06 01:02:08 作者:南简

我更新了我的内部版本对Android 1.6的,现在我的位图上高密度的屏幕缩小。我不希望这种行为。我这给了一个镜头:

http://blog.tomgibara.com/post/190539066/android-未缩放,位图

但图像依然缩放,即除非我将它们设置为一个特定的高度和放大器;宽度。如果我使用 WRAP_CONTENT 他们正在缩小。

我必须使用缩放的位图加载器来创建一个可绘制的图像加载器,像这样:

 位图BM = UnscaledBitmapLoader.loadFromResource(imageBufferInputStream);
绘制=新BitmapDrawable(BM);
 

这是我后来分配给像这样一个ImageView的:

  imageView.setImageDrawable(copyBitmapDrawable((BitmapDrawable)绘制));
 

解决方案

结束语与绘制对象位图的问题。该绘制对象缩放位图。而不是使用的绘制对象,指定位图的ImageView 直接用 imageView.setImageBitmap(位图)

I updated my build to build against Android 1.6, and now my bitmaps are scaled down on high density screens. I do NOT want this behavior. I gave this a shot:

http://blog.tomgibara.com/post/190539066/android-unscaled-bitmaps

but the images are STILL scaling, that is UNLESS I set them to a specific height & width. If I use wrap_content they are scaled down.

I have an image loader using the unscaled bitmap loader to create a drawable like so:

Bitmap bm = UnscaledBitmapLoader.loadFromResource(imageBufferInputStream);
drawable = new BitmapDrawable(bm);

which I later assign to an ImageView like so:

imageView.setImageDrawable( copyBitmapDrawable( (BitmapDrawable) drawable) );

解决方案

Wrapping the bitmap with a Drawable is the problem. The Drawable scales the Bitmap. Instead of using a Drawable, assign the Bitmap to the ImageView directly using imageView.setImageBitmap(Bitmap).