3

I have a custom view that is showing an image inside a shape. I used BitmapShader to fit my image into the shape with TileMode is CLAMP Now I have a problem that when I am moving my image (using setLocalMatrix method) it make my image become terrible. here is my image when moving around: enter image description here

Here is my code:

BitmapShader shader=new BitmapShader(sbmp, TileMode.CLAMP, TileMode.CLAMP);
Matrix currMatrix = new Matrix(this.getMatrix());
currMatrix.postTranslate(currX, currY); 
shader.setLocalMatrix(currMatrix);
mpaint.setShader(shader);
Hamad
  • 5,096
  • 13
  • 37
  • 65
Newbie
  • 41
  • 3

1 Answers1

0

You can translate image with instead of localMatrix

int i = canvas.save();
canvas.translate(currX, currY);
//Here draw image
canvas.restoreToCount(i);
Drake29a
  • 896
  • 8
  • 23