0

I have created a bitmap that I want to use for a BitmapShader.

The bitmap and the result after using it with a BitmapShader and a paint object looks as follows: Ignore the word 'new game' on the left picture. The bitmap does not have that word in it

enter image description here

I was expecting to get a nice double color border all around. The colors of the bitmap are separated. Why is it doing this?

Here is the code of how I create the paint object and the bitmapshader:

    strokePaint = new Paint();
    strokePaint.setAntiAlias(true);
    strokePaint.setStyle(Paint.Style.STROKE);
    strokePaint.setStrokeWidth(21f);
    strokePaint.setStrokeCap(Paint.Cap.ROUND);
    strokePaint.setStrokeJoin(Paint.Join.ROUND);

BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    strokePaint.setShader(shader);
i_o
  • 777
  • 9
  • 25
  • Please post the original bitmap too. – blackapps Dec 04 '22 at 08:58
  • @blackapps the original bitmap is the one on the left side.. it is created in code and it shows like that. – i_o Dec 04 '22 at 09:00
  • Dont understand. The shader should do something with the original bitmap. So the result should be different from it. But you expect the result to be the same bitmap? Cant follow you – blackapps Dec 04 '22 at 09:04
  • @blackapps I expect the border to look like a checkered border. red and green not half of the border red and the other half green. I did make the bitmap smaller like 100 px and now the checkered bordered is showing! Should play with the ClampMode and see what happens – i_o Dec 04 '22 at 09:07
  • All I had to do was to make the bitmap much smaller. Now the pattern of red and green shows, but the top and bottom edge are just one color. How can I make the pattern show for the top and bottom edge? – i_o Dec 04 '22 at 09:22

0 Answers0