更改ImageView的质量

问题描述:

我有一个ImageView,大小为70dp,宽度和高度。它用于我的ListView并包含800x800的图像src。更改ImageView的质量

我现在的问题是,这张图片太大了,它看起来太在我的ImageView。 我该如何预防?

<ImageView 
    android:id="@+id/imageView_albumart" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:layout_width="70dp" 
    android:layout_height="70dp" 
    android:layout_marginRight="5dp" 
    android:src="@drawable/cd_800x800" /> 

其实你可以玩你的位图。旋转,压缩,转换其他格式等。 我们在下面的代码中将质量从100降低到25。

因此,这是代码:

Bitmap oldbitmap=Bitmap bitmap = ((BitmapDrawable)yourimageview.getDrawable()).getBitmap(); 
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
    oldbitmap.compress(Bitmap.CompressFormat.JPEG, 25,baos); 
    Bitmap newbitmap=BitmapFactory.decodeStream(new ByteArrayInputStream(baos.toByteArray())); 
    yourimageview.setImageBitmap(newbitmap); 
+0

这确实didnt帮助过我的ImageView还是很犀利。 Yerim seni –

+1

Bitmap scaled = Bitmap.createScaledBitmap(yourBitmap,300,300,true);这是分辨率下降到300x300 bizdeçaretükenmez.. –

+0

谢谢你的帮助,但我想我必须模糊的图片有点因为它仍然非常尖锐莫名其妙。 Eyvallah kardesim steamin varsa beni adlersen sevinirim:http://steamcommunity.com/profiles/76561198227006600 –