アプリの高さと幅の理想的な比率に応じて画像のサイズを変更する機能があります。問題は、画像のサイズを変更しようとすると画像の品質です。サイズを変更すると、多くの品質が失われます。塗装したのですが、品質を上げる方法はありますか?
完全な画像比率 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);
}