小编use*_*764的帖子

Android将位图旋转90度会导致压缩图像.需要在纵向和横向之间进行真正的旋转

我试图将位图图像旋转90度,将其从横向格式更改为纵向格式.例:

[a,b,c,d]
[e,f,g,h]
[i,j,k,l]

顺时针旋转90度变为

[i,e,a]
[j,f,b]
[k,g,c]
[l,h,d]

使用下面的代码(来自在线示例),图像旋转90度,但保留横向纵横比,因此您最终得到一个垂直压扁的图像.难道我做错了什么?我需要使用另一种方法吗?我也愿意旋转我用来创建位图的jpeg文件,如果这更容易的话.

 // create a matrix for the manipulation
 Matrix matrix = new Matrix();
 // resize the bit map
 matrix.postScale(scaleWidth, scaleHeight);
 // rotate the Bitmap
 matrix.postRotate(90);

 // recreate the new Bitmap
 Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOriginal, 0, 0, widthOriginal, heightOriginal, matrix, true); 
Run Code Online (Sandbox Code Playgroud)

android bitmap rotation

18
推荐指数
2
解决办法
3万
查看次数

标签 统计

android ×1

bitmap ×1

rotation ×1