How can I show a thumbnail from a fixed image path in an ImageView?
Asked
Active
Viewed 8,027 times
1 Answers
8
you can create Image thumbnail from the image path as:
public Bitmap getbitpam(String path){
Bitmap imgthumBitmap=null;
try
{
final int THUMBNAIL_SIZE = 64;
FileInputStream fis = new FileInputStream(path);
imgthumBitmap = BitmapFactory.decodeStream(fis);
imgthumBitmap = Bitmap.createScaledBitmap(imgthumBitmap,
THUMBNAIL_SIZE, THUMBNAIL_SIZE, false);
ByteArrayOutputStream bytearroutstream = new ByteArrayOutputStream();
imgthumBitmap.compress(Bitmap.CompressFormat.JPEG, 100,bytearroutstream);
}
catch(Exception ex) {
}
return imgthumBitmap;
}
call this method on filepath click to show Image thumbnail in ImageView
ρяσѕρєя K
- 130,641
- 51
- 193
- 212
-
1Don't forget to handle OOM exceptions, maybe you have large pictures as well. – Marius M Dec 14 '12 at 08:38
-
Thanks so much this worked for me :) – Marco Seiz Dec 14 '12 at 12:35