Android 一些工具类/方法收藏
16lz
2021-01-23
public Bitmap formatBitMapSize(Bitmap bitmapOrg, int twidth, int theight) {// 获取这个图片的宽和高int width = bitmapOrg.getWidth();int height = bitmapOrg.getHeight();// 定义预转换成的图片的宽度和高度int newWidth = twidth;int newHeight = theight;// 计算缩放率,新尺寸除原始尺寸float scaleWidth = ((float) newWidth) / width;float scaleHeight = ((float) newHeight) / height;// 创建操作图片用的matrix对象Matrix matrix = new Matrix();// 缩放图片动作matrix.postScale(scaleWidth, scaleHeight);// 旋转45度// matrix.postRotate(45);// 生成新的bitmapBitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width,height, matrix, true);return resizedBitmap;}
……代加
更多相关文章
- android调用系统摄像头拍照图片和视频
- 【Android通过手势实现的缩放处理】
- android数据库中存取图片
- 【TabHost】Android设置TabHost文字及图片
- 图片url地址转换成file文件
- android下载网络图片并缓存
- Android 通过Matrix来对图片进行缩放,旋转和平移
- android实现图片上传功能(springMvc)