Answer the question
In order to leave comments, you need to log in
How to calculate alpha channel knowing background color and brush color?
Known background color and brush color. Let's say background color: black, brush color: white. 0.5 alpha channel will give the color: 7f7f7f (hexadecimal rgb). How can this be calculated mathematically?
Answer the question
In order to leave comments, you need to log in
If I understand correctly, then the answer is here - https://stackoverflow.com/questions/11614940/conve...
alpha = 1 - RGBA.alpha;
RGB.red = Math.round((RGBA.alpha * (RGBA.red / 255) + (alpha * (bg.red / 255))) * 255);
RGB.green = Math.round((RGBA.alpha * (RGBA.green / 255) + (alpha * (bg.green / 255))) * 255);
RGB.blue = Math.round((RGBA.alpha * (RGBA.blue / 255) + (alpha * (bg.blue / 255))) * 255);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question