当我在应用程序中调整一个图像位图的大小时,出现问题,图像质量下降。调整大小时Android的质量不佳位图
我调整大小的代码如下..
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;
}
调整大小的位图¿什么好的解决办法?
参考这个网址http://android.okhelp.cz/resize-a-bitmap-image-android-example/和HTTP:// thinkandroid.wordpress.com/2009/12/25/resizing-a-bitmap/ –
为什么你不只是使用'Bitmap.createScaledBitmap(bm,newWidth,newHeight,true)'? –