天天看点

将bitmap转换成任意大小

将bitmap转换成任意大小

public Bitmap resizeBitmap(float newWidth, float newHeight, Bitmap bitmap) {

Matrix matrix = new Matrix(); matrix.postScale(newWidth / bitmap.getWidth(),

newHeight / bitmap.getHeight());

Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),

bitmap.getHeight(), matrix, true);

return newBitmap;

}