Question

I don't know if this community is the right place for this kind of questions but probably is...

This is the first time I have to "work" with color theory so I don't know much about it... This time I'll only have grayscale pictures so it will be easyer i hope.

I need to get a gradient out of an image for a java project. What I have is a flat gray background image with a simple dark gradient on it. Example
And i want to get a transparent gradient like this.

With some tricks on photoshop I found out that if my background color is RGB(83,83,83) a pixel in the starting image that is RGB(57,57,57) in my result image will be a 31%(transparence) black.

I could build a java app with some bufferedimages but I don't know the maths behind this 31%...

So i need a math rule to substract two grays and get a transparent black :)
Thanks.

Was it helpful?

Solution

(1 - 57/83) * 100%  = 31.3%

This resembles some alpha blending formula.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top