Which is going to be the better (use less heap space) way for setting an ImageView’s image?
imageView.setImageDrawable(Drawable.createFromPath(path));
or
imageView.setImageBitmap(BitmapFactory.decodeFile(path));
or
is = new FileInputStream(path);
imageView.setImageBitmap(BitmapFactory.decodeStream(is));
is.close();
The BitmapFactory will let me set an inSampleSize, so I don’t pull too large a bitmap. Would the Drawable do anything like that for me?
Are there advantage to the BitmapFactory.decodeStream over BitmapFactory.decodeFile?
There should be no difference between
decodeStream()anddecodeFile(). In fact,decodeFile()does the same thing you do here. It opens an inputstream and callsdecodeStream(). See the source.And
Drawable.createFromPath()also just callsBitmapFactory.decodeFile(). So it’s in any case the same work/functionality.