0

I want to create a "glow" effect on top of an image. On dark it's almost working, but on bright images you can see a gray rectangle on image, as seen in below image:

image gradient effect

Here is my code:

    public static Bitmap drawModifiedImage(Bitmap bitmap) {
    Canvas bigCanvas = new Canvas(bitmap);
    Bitmap b = Bitmap.createBitmap(bitmap.getWidth(), 20, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    c.drawColor(Color.TRANSPARENT);
    LinearGradient grad = new LinearGradient(bitmap.getWidth()/2, 0, bitmap.getWidth()/2, 20, Color.WHITE, Color.TRANSPARENT, Shader.TileMode.CLAMP);
    Paint p = new Paint();
    p.setStyle(Paint.Style.FILL);
    p.setShader(grad);
    c.drawRect(0, 0, bitmap.getWidth(), 20, p);
    bigCanvas.drawBitmap(bitmap, 0, 0, null);
    bigCanvas.drawBitmap(b,0,0, null);
    return bitmap;
}

What am I doing wrong?

1 Answer 1

2

I've found the answer. Instead of Color.TRANSPARENT, I've used 0X00FFFFFF:

LinearGradient grad = new LinearGradient(bitmap.getWidth()/2, 0, bitmap.getWidth()/2, 20, Color.WHITE, 0X00FFFFFF, Shader.TileMode.CLAMP);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.