【自用】Kotlin Bitmap 缩放 翻转
2017-06-07 00:00
204 查看
//使用Bitmap加Matrix来缩放 fun resizeImage(bitmap: Bitmap, width: Int, height: Int): Bitmap { val bmpWidth = bitmap.width val bmpHeight = bitmap.height val scaleWidth = width.toFloat() / bmpWidth val scaleHeight = height.toFloat() / bmpHeight val matrix = Matrix() matrix.postScale(scaleWidth, scaleHeight) return Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true) }
//使用Bitmap加Matrix来翻转 fun horverImage(bitmap: Bitmap, H: Boolean, V: Boolean): Bitmap { val bmpWidth = bitmap.width val bmpHeight = bitmap.height val matrix = Matrix() if (H) matrix.postScale(-1f, 1f) //水平翻转H if (V) matrix.postScale(1f, -1f) //垂直翻转V if (H && V) matrix.postScale(-1f, -1f) //水平&垂直翻转HV return Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true) //matrix.postRotate(-90); //旋转-90度 }
相关文章推荐
- (转AS3)利用BitmapData.draw对位图进行翻转缩放操作
- (AS3)利用BitmapData.draw对位图进行翻转缩放操作
- 【自用】Android | Bitmap的水平&垂直翻转
- 【自用】Kotlin bitmapCutting
- 自定义View2 ,自定义路径,bitmap图像处理(缩放,翻转之类,还有Matrix和Mode)
- Android 绘图基础:Bitmap(位图)与Matrix(矩阵)实现图片5种操作(平移、旋转、错切、缩放、对称)
- 【自用】sklearn 特征缩放 MinMaxScaler
- 处理图片的缩放、旋转、裁剪和翻转这四种效果
- java 实现图片的缩放、翻转
- cocos2d-x精灵图片翻转、缩放等操作[转载]
- 对Bitmap 进行水平或者垂直的镜面翻转
- Android学习笔记之Bitmap位图的缩放
- Android 缩放bitmap的函数
- 图片处理(旋转,平移,缩放)View---Canvas;Paint;Bitmap
- Android如何缩放图片以及Drawable转Bitmap方法
- 如何使用Matrix对bitmap的旋转与镜像水平垂直翻转
- Bitmap位图的旋转与缩放
- Bitmap旋转和缩放
- Android Bitmap 常见的几个操作:缩放,裁剪,旋转,偏移
- java图片旋转,缩放,翻转