public Bitmap getNewBitmap(Bitmap bitmap, int newWidth ,int newHeight){ // 获得图片的宽高. int width = bitmap.getWidth(); int height = bitmap.getHeight(); // 计算缩放比例. float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // 取得想要缩放的matrix参数. Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); // 得到新的图片. Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); return newBitmap; }
Android中通过代码修改bitmap的宽高
猜你喜欢
转载自blog.csdn.net/zmesky/article/details/80436159
今日推荐
周排行