Bonjour,

1) Je voudrais effectuer un sous echantillonnage dynamique en fonction de la taille de l'image mais je ne sais pas comment faire.

2) J'utilise la classe Gallery, comment faire pour que les images tiennent tout l'écran si nécessaire.

Voici l'extrait de mon code:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeStream(fis,null, options);
int heightRatio = (int) Math.ceil(options.outHeight/ (float) height);
int widthRatio = (int) Math.ceil(options.outWidth/ (float) width);
 
	if (heightRatio > 1 || widthRatio > 1) {
		if (heightRatio > widthRatio) {
			options.inSampleSize = heightRatio;
		} else {
			options.inSampleSize = widthRatio;
		}
	}
 
options.inJustDecodeBounds = false;
FileInputStream fis = new FileInputStream(imageFile);
SoftReference<Bitmap> preview = new SoftReference<Bitmap>(
	BitmapFactory.decodeStream(fis, null, options));
fis.close();
imageView.setImageBitmap(preview.get());
width et height, je ne sais pas comment les récupérer.

Merci.