【发布时间】:2020-04-03 19:19:36
【问题描述】:
我有以下代码:
private RectF tmpRect = new RectF();
public void drawClipedBitmap(Bitmap bmp, Polygon tmpPoly, int x, int y) {
this.canvas.clipPath(getPath(tmpPoly));
this.canvas.drawBitmap(bmp, (float) x, (float) y, this.fillPaint);
this.tmpRect.set(0.0f, 0.0f, (float) this.canvas.getWidth(), (float) this.canvas.getHeight());
this.canvas.clipRect(this.tmpRect, Op.REPLACE);
}
但自 Android SDK28 以来,clipRect 的实现已被弃用并退出。 我尝试了 4 个小时以找到一种方法来用其他方法替换该方法,但未成功。
由于 clipRect 已被弃用且不再工作,我如何获得相同的结果?
【问题讨论】:
-
不清楚
this.tmpRect()是什么,但你可能只使用Canvas.save()/restore()。