IAmGroot
IAmGroot

Reputation: 13865

Bitmap Shader with alpha channel. (Alpha is drawing black..?)

I get my bitmap, use it as a shader tile mode.

The PNG is mostly alpha except for the shape outline to draw.

Except it draws the outline, but is surrounded by black, not seethrough (alpha).

    pnt.reset();

    if(backgroundColor == 1)
    {   
            pnt.setColor(myColor);
            pnt.setStyle(Paint.Style.FILL);

    }

     m_canvas.drawPath(path, pnt);

//fillBMP = getBitmapFromAsset(m_context, "brush.png"); 
    fillBMP = BitmapFactory.decodeFile(mySDPath + "brush.png");
fillBMPshader = new BitmapShader(fillBMP, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);  

pnt.setShader(fillBMPshader);  

m_canvas.drawPath(path, pnt);

Example below of the brush on left. But result it draws on right.

enter image description here

Upvotes: 1

Views: 3092

Answers (1)

Ron
Ron

Reputation: 24235

You should set XferMode on your Paint object. More specifically you got to use PorterDuffXferMode MULTIPLY.

Here is a similar question : Android color overlay - PorterDuff modes

Upvotes: 2

Related Questions