/ / Immagine sfocata in Android - Android

Immagine sfocata in Android - Android

L'immagine appare sfocata quando la ottengo dalla galleria. Ridimensiono a 250w * 300h utilizzando il seguente codice:

        if(bm!=null)
{
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,true);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

Come posso risolvere questo?.

risposte:

1 per risposta № 1

Non hai bisogno che la manipolazione a matrice usi semplicemente

resizedBitmap = Bitmap.createScaledBitmap(bm, w, h, true);

Non sono sicuro di come calcoli newWidth e newHeight, ma potrebbe essere che la tua nuova bitmap ridimensionata sia troppo piccola e quindi le strisce in una vista quindi sfocate.