how to rotate a bitmap 90 degrees

后端 未结 10 1595
离开以前
离开以前 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:42

    public static Bitmap RotateBitmap(Bitmap source, float angle)
    {
          Matrix matrix = new Matrix();
          matrix.postRotate(angle);
          return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    }
    

    To get Bitmap from resources:

    Bitmap source = BitmapFactory.decodeResource(this.getResources(), R.drawable.your_img);
    

提交回复
热议问题