2015-01-21 7 views
0

휴대 전화의 sdcard에있는 HD 이미지를 보여주는 간단한 프로그램을 만들고 있습니다. 내 코드는sd 카드의 이미지 뷰에 hd 이미지 표시

ImageView iv=(ImageView)findViewById(R.id.imageView1); 
    File f = new File("/sdcard/mytestdownloadedfile2.jpg"); 
    Bitmap bmp = BitmapFactory.decodeFile(f.getAbsolutePath()); 
    iv.setImageBitmap(bmp); 

입니다. 내 코드를 실행하면 어떤 이미지도 표시되지 않지만이 HD 사진을 별표가있는 사진 또는 png로 바꿀 때 표시됩니다. 아무런 문제없이 보여줍니다. 그러니 제발 도와주세요.

+0

이 질문의 코드를 시도 작동하는지 알려 주시기 위해이 방법을 사용해보십시오 : http://stackoverflow.com/questions/15377186/decode-file-from-sdcard를 -android-to-avoid-out-of-large-bitmap으로 인한 메모리 부족 오류 – samgak

+0

이미지를 공유하거나 이미지 색상 공간을 나타낼 수 있습니까? –

+0

그것이 링크입니다. (http://wallpaperswide.com/download/the_forbidden_forest-wallpaper-2560x1440.jpg) – Pankaj

답변

0

, 파일을 디코딩이

public static Bitmap decodeScaledBitmapFromSdCard(String filePath, 
     int reqWidth, int reqHeight) { 

    // First decode with inJustDecodeBounds=true to check dimensions 
    final BitmapFactory.Options options = new BitmapFactory.Options(); 
    options.inJustDecodeBounds = true; 
    BitmapFactory.decodeFile(filePath, options); 

    // Calculate inSampleSize 
    options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); 

    // Decode bitmap with inSampleSize set 
    options.inJustDecodeBounds = false; 
    return BitmapFactory.decodeFile(filePath, options); 
} 
+0

선생님. 내 사진보기에서 하나의 HD 이미지 만 보여주는 내 사진 품질을 변경하고 싶지 않습니다. – Pankaj

+0

이렇게 할 수 있습니다. – Pankaj

관련 문제