我有一个函数可以根据我的应用程序的高度和宽度之间的理想比例调整图像大小问题是图像的质量当我尝试调整图像大小时它会失去很多质量它会像你调整大小一样被像素化它在油漆上,有什么方法可以提高质量?
完美的图像比例 0,744 (320x430) 有我的代码
public Bitmap redimensionarImagenMaximo(Bitmap mBitmap, float newWidth, float newHeigth){
//Redimensionamos
int width = mBitmap.getWidth();
int height = mBitmap.getHeight();
float actual = (float)width/height;
double perfect = 0.7441;
float scaleWidth;
float scaleHeight;
if(perfect >= actual)
{
scaleHeight = ((float) newHeigth) / height;
scaleWidth = scaleHeight;
}
else if(perfect <= actual)
{
scaleWidth = ((float) newWidth) / width;
scaleHeight = scaleWidth;
}
else
{
scaleWidth = newWidth;
scaleHeight = newHeigth;
}
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
return Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix, false);
}