Android中传入一个角度一张图片 返回旋转后的Bitmap.
2017-05-25 17:17
405 查看
1.方法:
public static Bitmap RotateBitmap(int angle, Bitmap bitmap) {
// 旋转图片 动作
Matrix matrix = new Matrix();
matrix.postRotate(angle);
// 创建新的图片
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
if (resizedBitmap != bitmap && bitmap != null && !bitmap.isRecycled()) {
try {
bitmap.recycle();
} catch (Exception e) {
}
}
return resizedBitmap;
}
public static Bitmap RotateBitmap(int angle, Bitmap bitmap) {
// 旋转图片 动作
Matrix matrix = new Matrix();
matrix.postRotate(angle);
// 创建新的图片
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
if (resizedBitmap != bitmap && bitmap != null && !bitmap.isRecycled()) {
try {
bitmap.recycle();
} catch (Exception e) {
}
}
return resizedBitmap;
}
相关文章推荐
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- Android异步从网络加载图片BitmapFactory.decodeStream 返回null的问题
- Android图片旋转,缩放,位移,倾斜,对称完整示例(二)——Bitmap.createBitmap()和Matrix
- android Drawbitmap 画一个图片(Rect 的作用)
- android开发 怎么在应用中调取图片库 选择一张图片 返回自己的应用中
- android Bitmap围绕一个点进行旋转
- Android 根据角度旋转图片
- android 将一个bitmap保存成图片文件
- android Bitmap拷贝一张图片
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- android Bitmap围绕一个点进行旋转
- android 计算Bitmap占byte大小,以及Bitmap中像素数的计算,另外再给出一个按尺寸裁剪图片的方法
- ios 给出一张图片,返回一个指定大小的图片
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byte
- android 将图片内容解析成字节数组,将字节数组转换为ImageView可调用的Bitmap对象,图片缩放,把字节数组保存为一个文件,把Bitmap转Byt
- 1.6 给出一张图片,表示为NXN的居然,每个像素点为4字节。写一个函数实现将这张图片旋转90°。
- 关于android中调用系统拍照,返回图片是旋转90度..
- android 图片Bitmap的旋转
- Android 根据角度旋转图片 ExifInterface