当我在我的应用程序中调整一个图像位图的大小时,我遇到了一个问题,图像质量下降。
我的调整大小代码如下..
public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight,
Config.ARGB_8888);
float ratioX = newWidth / (float) bm.getWidth();
float ratioY = newHeight / (float) bm.getHeight();
float middleX = newWidth / 2.0f;
float middleY = newHeight / 2.0f;
Matrix scaleMatrix = new Matrix();
scaleMatrix.postScale(ratioX, ratioY, middleX, middleY);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
Canvas canvas = new Canvas(scaledBitmap);
canvas.setMatrix(scaleMatrix);
canvas.drawBitmap(bm, middleX - bm.getWidth() / 2,
middleY - bm.getHeight() / 2, paint);
return scaledBitmap;
}
调整位图大小的任何好的解决方案¿?