android画布放大,canvas.getClipBounds()。左边是0总是在android而放大画布 - canvas.getClipB...

博客讨论了在Android应用中缩放Canvas时,使用getClipBounds().left和.getClipBounds().top始终返回0的问题。作者检查了缩放过程中保存、恢复以及路径绘制的代码,并提出了可能存在的实现错误。文章探讨了缩放手势检测和Canvas缩放的交互,但这两个值在缩放时并未更新。
摘要由CSDN通过智能技术生成

canvas.getClipBounds()。左边是0总是在android而放大画布 - canvas.getClipBounds().left is 0 always while zooming canvas in android

- 此内容更新于:2015-10-29

主题:

缩放后的帆布canvas.getClipBounds的价值()。离开总是0canvas.getClipBounds()。前总是0这些值缩放时从不改变。有任何错误的实现吗?

原文:

After zooming Canvas the value of

canvas.getClipBounds().left is always 0

canvas.getClipBounds().top is always 0

These value never changes while zooming.Is there any wrong implementation?

Rect clipBounds = new Rect();

int canvasLeft;

@Override

protected void onDraw(Canvas canvas) {

super.onDraw(canvas);

clipBounds = canvas.getClipBounds();

canvas.save();

canvasLeft = canvas.getClipBounds().left;

if(scaleGestureDetector.isInProgress()){

scaleGestureFocusX = this.scaleGestureDetector.getFocusX();

scaleGestureFocusY = this.scaleGestureDetector.getFocusY();

canvas.scale(this.scaleFactor, this.scaleFactor, scaleGestureFocusX, scaleGestureFocusY);

}

else{

canvas.scale(this.scaleFactor, this.scaleFactor, scaleGestureFocusX, scaleGestureFocusY);

}

canvas.drawBitmap(bitmap, 0, 0, null);

canvas.drawPath(path, paint);

canvas.restore();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值