绘制位图并将其旋转到特定位置

时间:2018-11-15 12:47:27

标签: java android android-custom-view

Bitmap pen=bluePen;
    int targetX=screenWidth/2;
    int targetY=screenHeight/2;
    int left=targetX-pen.getWidth()/2;
    int right=targetX+pen.getWidth()/2;
    int top=targetY;
    int bottom=targetY+pen.getHeight();
    RectF rectInScreenToWrapMyPencil=new RectF(left,top,right,bottom);
    RectF pencilRect=new RectF(0,0,pen.getWidth(),pen.getHeight());
    Matrix matrix=new Matrix();
    matrix.mapRect(rectInScreenToWrapMyPencil,pencilRect);
    matrix.setRotate(45);
    canvas.drawBitmap(pen,matrix,null);

大家好,我想绘制一个可通过centerX()和屏幕顶部位置旋转的矩形位图,但是当我运行此代码时,位图被淹没并且可以旋转但在特定位置没有被淹没 有人可以告诉我如何解决吗?

0 个答案:

没有答案