Code example for Resources

Methods: getDisplayMetrics

0
	private final float mBackupSize;
 
	public GLImageLoader(final Context context, final DownloadListener listener, final Uri uri) {
		super(context, listener, uri);
		final Resources res = context.getResources();
		final DisplayMetrics dm = res.getDisplayMetrics();
		mBackupSize = Math.max(dm.heightPixels, dm.widthPixels);
	} 
 
	@Override 
	protected AbstractImageLoader.Result decodeImage(final FileDescriptor fd) {
		try { 
			final BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(fd, false);
			final int width = decoder.getWidth();
			final int height = decoder.getHeight();
			final BitmapFactory.Options options = new BitmapFactory.Options();
			options.inSampleSize = BitmapUtils.computeSampleSize(mBackupSize / Math.max(width, height));
			final Bitmap bitmap = decoder.decodeRegion(new Rect(0, 0, width, height), options);
			return new GLImageResult(decoder, bitmap, Exif.getOrientation(fd), mImageFile);
		} catch (final IOException e) {
			final BitmapFactory.Options o1 = new BitmapFactory.Options();