我正在开发一个应用程序 . 我在其中使用canvas并在其中绘制位图图像 .

我将视频作为具有分辨率(例如800 x 600)的字节作为宽度和高度,我将其转换为具有相同宽度和高度的位图图像 .

转换位图图像后,我调用画布,我创建一个目标矩形 . 并调用此方法

canvas.createbitmap(位图,src rect,目标rect);

一切正常 . 位图图像适合目标矩形 .

  • 但如果我将图像旋转90%,我需要以旋转角度显示图像 . 但我无法完成它 . 图像被拉伸并适合目标矩形 .

我想实现并看到旋转的图像,因为它是在画布内 . 我不想要拉伸的图像 .

请告诉我如何添加位图图像,而无需重新调整大小以适应目标矩形 .

Bitmap bmp = null
     byte[] data = videoInfo.getData();
     ByteBuffer buf = ByteBuffer.wrap(data);
     buf.rewind();
     Bitmap bmp = Bitmap.createBitmap(videoInfo.getWidth(), videoInfo.getHeight(),  Bitmap.Config.RGB_565);
     bmp.copyPixelsFromBuffer(buf);     

      int dstLeft = miLeft;
      int dstTop = miTop;
      int dstRight = dstLeft + miWidth;
      int dstBottom = dstTop + miHeight;
      Rect dst = new Rect(dstLeft, dstTop, dstRight, dstBottom);

      Rect src = null;     

     canvas.drawBitmap(bmp, src, dst, null);