Tengo un mapa de bits ... y si la altura del mapa de bits es mayor que maxHeight, o el ancho es mayor que maxWidth, me gustaría cambiar proporcionalmente la imagen para que quepa en maxWidth X Altura máxima. Esto es lo que estoy tratando:Redimensionar proporcionalmente un mapa de bits
BitmapDrawable bmp = new BitmapDrawable(getResources(), PHOTO_PATH);
int width = bmp.getIntrinsicWidth();
int height = bmp.getIntrinsicHeight();
float ratio = (float)width/(float)height;
float scaleWidth = width;
float scaleHeight = height;
if((float)mMaxWidth/(float)mMaxHeight > ratio) {
scaleWidth = (float)mMaxHeight * ratio;
}
else {
scaleHeight = (float)mMaxWidth/ratio;
}
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap out = Bitmap.createBitmap(bmp.getBitmap(),
0, 0, width, height, matrix, true);
try {
out.compress(Bitmap.CompressFormat.JPEG, 100,
new FileOutputStream(PHOTO_PATH));
}
catch(FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
consigo la siguiente excepción:
java.lang.IllegalArgumentException: bitmap size exceeds 32bits
¿qué estoy haciendo mal aquí?
Puede usted más allá del código corregido aquí? Estoy recibiendo la misma excepción – Mahesh