2012-05-05 41 views
0

我從url加載ImageView中的圖片。 (來自RSS提要)從url中加載圖片的分辨率問題

問題是加載的圖像的分辨率低於原始圖像!

我搜索了Stackoverflow,發現解決方法是將「inScaled」選項設置爲false以防止圖像重新縮放。 但是,這種解決方案並不適合我。

下面是代碼:

URL feedImage= new URL(img_link); 
    HttpURLConnection conn= (HttpURLConnection)feedImage.openConnection(); 
    InputStream is = conn.getInputStream(); 
    BitmapFactory.Options BFoptions = new BitmapFactory.Options(); 
    BFoptions.inScaled = false; 
    Bitmap img = BitmapFactory.decodeStream(is,null, BFoptions); 
    int density = img.getDensity(); Log.e("img", "Image density is " + density); 
    int width =img.getWidth(); Log.e("img", "Image width is " + width); 
    int height = img.getHeight(); Log.e("img", "Image height is " + height); 

    my_image.setImageBitmap(img); 

變量密度,寬度和高度是比原始圖像的值低。

,這裏是我的佈局的一部分:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 


      <ImageView 
        android:id="@+id/joke_image" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"   
        android:contentDescription="temp description"/> 


      <ScrollView 
        android:id="@+id/SV" 
        android:layout_width="fill_parent" 
        android:layout_height="30dp" 
        android:background="@drawable/background" 
        android:paddingTop="10dp" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingBottom="50dp"> 

        <!-- bla 
         bla 
         bla 

         --> 


      </ScrollView> 
</RelativeLayout> 

在此先感謝

回答

0

最後,它解決了:)

這似乎是不相關的代碼或ImageViews, .....

RSS源中的所有圖像都是縮略圖...這是它們在應用程序中顯得很小但在網站上很大的原因。

因此,解決辦法是更換「_s.jpg」在每個圖像的URL與「_n.jpg」 :)

我希望這個答案將有助於結束別人:)