Sports/app/src/main/java/com/global/labs/utils/ImageLoader.java
private Bitmap decodeFile(File f, int w) {
		try {
			// decode image size
			BitmapFactory.Options o = new BitmapFactory.Options();
			o.inJustDecodeBounds = true;
			FileInputStream stream1 = new FileInputStream(f);
			BitmapFactory.decodeStream(stream1, null, o);
			stream1.close();
			// Find the correct scale value. It should be the power of 2.
			final int REQUIRED_SIZE = w;
			System.out.println("screen wdth " + widht);
			int width_tmp = o.outWidth, height_tmp = o.outHeight;
			System.out.println("image with === " + width_tmp);
			int scale = 1;
			while (true) {
				if (width_tmp / 2 < REQUIRED_SIZE
						|| height_tmp / 2 < REQUIRED_SIZE)
					break;
				width_tmp /= 2;
				height_tmp /= 2;
				scale *= 2;
			}

			// decode with inSampleSize
			BitmapFactory.Options o2 = new BitmapFactory.Options();
			o2.inSampleSize = scale;
			FileInputStream stream2 = new FileInputStream(f);
			Bitmap bitmap = BitmapFactory.decodeStream(stream2, null, o2);
			stream2.close();
			return bitmap;
		} catch (FileNotFoundException e) {
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
// decodes image and scales it to reduce memory consumption
decodes image and scales it to reduce memory consumption
decodes image and scales it to reduce memory consumption
private Bitmap decodeFile(File f, int w) {
		try {
			BitmapFactory.Options o = new BitmapFactory.Options();
			o.inJustDecodeBounds = true;
			FileInputStream stream1 = new FileInputStream(f);
			BitmapFactory.decodeStream(stream1, null, o);
			stream1.close();
			final int REQUIRED_SIZE = w;
			System.out.println("screen wdth " + widht);
			int width_tmp = o.outWidth, height_tmp = o.outHeight;
			System.out.println("image with === " + width_tmp);
			int scale = 1;
			while (true) {
				if (width_tmp / 2 < REQUIRED_SIZE
						|| height_tmp / 2 < REQUIRED_SIZE)
					break;
				width_tmp /= 2;
				height_tmp /= 2;
				scale *= 2;
			}
			BitmapFactory.Options o2 = new BitmapFactory.Options();
			o2.inSampleSize = scale;
			FileInputStream stream2 = new FileInputStream(f);
			Bitmap bitmap = BitmapFactory.decodeStream(stream2, null, o2);
			stream2.close();
			return bitmap;
		} catch (FileNotFoundException e) {
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
private Bitmap decodeFile ( File f , int w ) { try { BitmapFactory . Options o = new BitmapFactory . Options ( ) ; o . inJustDecodeBounds = true ; FileInputStream stream1 = new FileInputStream ( f ) ; BitmapFactory . decodeStream ( stream1 , null , o ) ; stream1 . close ( ) ; final int REQUIRED_SIZE = w ; System . out . println ( "screen wdth " + widht ) ; int width_tmp = o . outWidth , height_tmp = o . outHeight ; System . out . println ( "image with === " + width_tmp ) ; int scale = 1 ; while ( true ) { if ( width_tmp / 2 < REQUIRED_SIZE || height_tmp / 2 < REQUIRED_SIZE ) break ; width_tmp /= 2 ; height_tmp /= 2 ; scale *= 2 ; } BitmapFactory . Options o2 = new BitmapFactory . Options ( ) ; o2 . inSampleSize = scale ; FileInputStream stream2 = new FileInputStream ( f ) ; Bitmap bitmap = BitmapFactory . decodeStream ( stream2 , null , o2 ) ; stream2 . close ( ) ; return bitmap ; } catch ( FileNotFoundException e ) { } catch ( IOException e ) { e . printStackTrace ( ) ; } return null ; }
decodes image and scales it to reduce memory consumption
decodes image and scales it to reduce memory consumption
// decode image size // Find the correct scale value. It should be the power of 2. // decode with inSampleSize