68分!在线等bitmap中心点旋转问题~~~

活着便精彩 2011-04-26 02:04:26
现在有一张图 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写错了?
...全文
372 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
rekkkkkker 2011-05-26
  • 打赏
  • 举报
回复
有人知道吗
活着便精彩 2011-04-27
  • 打赏
  • 举报
回复
人气好少
活着便精彩 2011-04-27
  • 打赏
  • 举报
回复
/* 重置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的朋友 指教下 谢谢
yuchong1984 2011-04-27
  • 打赏
  • 举报
回复
android:pivotX="50%"
android:pivotY="50%"
就是中心旋转咯
WintelZhao 2011-04-26
  • 打赏
  • 举报
回复
Matrix matrix=new Matrix();
matrix.setRotate(Angle, 100, 50);
matrix.setTranslate(100, 100);

默认矩阵根据100,50旋转Angle角度,然后偏移至100,100。
后面代码你都会了~
活着便精彩 2011-04-26
  • 打赏
  • 举报
回复
LS不对啊
windreamworkup 2011-04-26
  • 打赏
  • 举报
回复
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);
活着便精彩 2011-04-26
  • 打赏
  • 举报
回复
谁有小的DEMO啊 给一个 谢谢
活着便精彩 2011-04-26
  • 打赏
  • 举报
回复
谁做过呢 说一下 谢谢
aSysBang 2011-04-26
  • 打赏
  • 举报
回复
可以参考
先x对称
再y对称
这个的坐标变换过程

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧