Code example for BitmapFactory.Options

Methods: decodeFiledecodeStream

0
		return null; 
	} 
 
	public static Bitmap getThumbBitmap(ImageInfo thumbInfo, Context context) {
 
		BitmapFactory.Options ops = new Options();
		String path = thumbInfo.getData();
		ops.inJustDecodeBounds = true;
		Bitmap bm = BitmapFactory.decodeFile(path, ops);
 
		int bitmapWidth = ops.outWidth;
		int bitmapHeight = ops.outHeight;
		int be = 1;
		if (bitmapHeight > bitmapWidth) {
			be = bitmapHeight / 150;
		} 
		else { 
			be = bitmapWidth / 150;
		} 
 
		if (be <= 0)
			be = 1;
		ops.inSampleSize = be;
		ops.inJustDecodeBounds = false;
		ops.inPreferredConfig = Bitmap.Config.RGB_565;
		ops.inPurgeable = true;
		ops.inInputShareable = true;
		// 
		// try { 
		// InputStream is = new FileInputStream(new File(thumbInfo.getData())); 
		// bm = BitmapFactory.decodeStream(is, null, ops); 
		// } catch (FileNotFoundException e) { 
		// // TODO Auto-generated catch block 
		// e.printStackTrace(); 
		// } 
 
		// bm = ThumbnailUtils.extractThumbnail(bm, 154, 154); 
 
		// Bitmap bm = 
		// MediaStore.Images.Thumbnails.getThumbnail(context.getContentResolver(), 
		// thumbInfo.getId(), 1, null); 
		// 
		// return bm; 
		try { 
			InputStream is = new FileInputStream(new File(thumbInfo.getData()));
			bm = BitmapFactory.decodeStream(is, null, ops);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
		return ImageUtil.extractThumbnail(bm, 120, 120);