I'm trying to fit a bitmap to a random size rect but I don't want the bitmap to be streched out. I've tried using BitmapShader and tile it but it become animated and not fixed.
Here is my code without BitmapShader.
public void draw(Canvas canvas) {
Paint paint = new Paint();
canvas.drawBitmap(spike1, null, rectangle, paint);
canvas.drawBitmap(spike1, null, rectangle2, paint);
}
Here is my code with BitmapShader.
public void draw(Canvas canvas) {
Paint paint = new Paint();
paint.setShader(new BitmapShader(spike1, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT));
canvas.drawRect(rectangle, paint);
canvas.drawRect(rectangle2, paint);
}
Here is a picture of my problems
Can somebody tell what I need to do so the image is fix but not stretched?