ImageView will not display image when setImageBitmap () is set

I'm having trouble displaying an existing image on an SD card.

ImageView _photoView = (ImageView)findViewById(R.id.img_photo); File photoFile = new File(Environment.getExternalStorageDirectory(), Session.PHOTO_FILE_NAME); rawFileInputStream = new FileInputStream(photoFile); Bitmap origPhoto = BitmapFactory.decodeStream(rawFileInputStream, null, new BitmapFactory.Options()); _photoView.setImageBitmap(origPhoto); Log.d(TAG, origPhoto.getWidth() + " - " + origPhoto.getHeight()); 

A photo exists and dimensions are displayed as shown, but nothing is displayed in the ImageView tag

 <ImageView android:id="@+id/img_photo" android:layout_width="fill_parent" android:layout_height="wrap_content" /> 

I tried to set the height to a fixed size, but I still can’t see the photo.

I saw several posts on this question, but none of them received an answer.

Any ideas?

** Update If I upload a file directly, and not through a stream, it works

 Bitmap origPhoto = BitmapFactory.decodeFile("/mnt/sdcard/" + Session.PHOTO_FILE_NAME); double scale = MAX_WIDTH * 1.0 / origPhoto.getWidth(); int height = (int)(origPhoto.getHeight() * scale); Bitmap scaledPhoto = Bitmap.createScaledBitmap(origPhoto, MAX_WIDTH, height, true); _photoView.setImageBitmap(origPhoto); 

but if I then add the method of the Bitmap.createScaledBitmap() method, then it no longer works and the image does not appear.

+7
source share
1 answer

I replaced the file stream with Bitmap scaledPhoto = BitmapFactory.decodeFile ("/ mnt / sdcard /" + Session.PHOTO_FILE_NAME); and now it works (as mentioned in the update)

0
source

All Articles