how to rotate a bitmap 90 degrees

后端 未结 10 1612
离开以前
离开以前 2020-11-28 03:09

There is a statement in android canvas.drawBitmap(visiblePage, 0, 0, paint);

When I add canvas.rotate(90), there is no effect. But if I wri

10条回答
  •  广开言路
    2020-11-28 03:47

    You can also try this one

    Matrix matrix = new Matrix();
    
    matrix.postRotate(90);
    
    Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmapOrg, width, height, true);
    
    Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true);
    

    Then you can use the rotated image to set in your imageview through

    imageView.setImageBitmap(rotatedBitmap);
    

提交回复
热议问题