现在有一张图  200*100,       left和top都是100。
现在我要把这张图按照中心点旋转,但是不行                 Matrix  mMatrix=new Matrix()
                 mMatrix.reset();

/* 设置旋转 */
if(tempwidth==0){
mMatrix.preRotate(Angle,100+BitQQwidth/2,100+BitQQheight/2);}
else{
mMatrix.preRotate(Angle,100+tempwidth/2,100+tempheight/2);
}

Bitmap mBitQQ2;

/* 按mMatrix得旋转构建新的Bitmap */
if(flag==0)
mBitQQ2 = Bitmap.createBitmap(mBitQQ, 0, 0, BitQQwidth,BitQQheight, mMatrix, true);
else
mBitQQ2 = Bitmap.createBitmap(mBitQQ, 0, 0, tempwidth,tempheight, mMatrix, true);

tempwidth=mBitQQ2.getWidth();
tempheight=mBitQQ2.getHeight();

/* 绘制旋转之后的图片 */
GameView.drawImage(canvas, mBitQQ2, 100, 100);这样不是以中心点对齐的谁给个例子  或者说下怎么做啊    中心点px,py写错了?

解决方案 »

  1.   

    谁有小的DEMO啊    给一个 谢谢
      

  2.   

    int width = originalImage.getWidth();
    int height = originalImage.getHeight();Matrix matrix = new Matrix();
    matrix.preScale(1, -1);Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0,
    height, width, height, matrix, false);
      

  3.   

    Matrix matrix=new Matrix();
    matrix.setRotate(Angle, 100, 50);
    matrix.setTranslate(100, 100);默认矩阵根据100,50旋转Angle角度,然后偏移至100,100。
    后面代码你都会了~
      

  4.   

    /* 重置mMatrix */
    mMatrix.reset();

    /* 设置旋转 */
    mMatrix.setRotate(Angle,100,50);
    mMatrix.setTranslate(100, 100);

    Bitmap mBitQQ2;
    /* 按mMatrix得旋转构建新的Bitmap */
    mBitQQ2 = Bitmap.createBitmap(mBitQQ, 0, 0, 200,100, mMatrix, true); /* 绘制旋转之后的图片 */
    canvas.drawBitmap(bitmap, 100,100, null); mBitQQ2 = null;这样也不行啊LS的朋友   指教下  谢谢
      

  5.   

    android:pivotX="50%"
    android:pivotY="50%"
    就是中心旋转咯