Reputation: 1612
I have the following code:
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);
}
But since Android SDK28 the implementation of clipRect was deprecated and dropped out. I am trying for 4 hours to find a way to replace that method with something else, unsuccessful.
How do I achieve same result since clipRect is deprecated and not working anymore?
Upvotes: 4
Views: 1295
Reputation: 1612
I have found by myself:
public void drawClipedBitmap(Bitmap bmp, Polygon tmpPoly, int x, int y) {
Path p = getPath(tmpPoly);
Log.d("POINTS","POINTS: "+p);
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);
this.canvas.save();
float fWidth = (float)this.canvas.getWidth();
float fHeight = (float)this.canvas.getHeight();
//this.canvas.drawRect(0, 0, fWidth, fHeight, new Paint());
this.canvas.clipRect(0.0f, 0.0f, fWidth, fHeight);
this.canvas.restore();
}
Upvotes: 1