1

I'm trying to compare the colors of different websites.

One website states its colors with RGBA and has for example rgba(0, 0, 0, 0.55) on a white background. I would like to convert the result into a hex color code.

Is there a straightforward converter for this task?

I would expect a Web app, but otherwise for Windows 10.

  • For everyone trying to answer this question: a tool that allows entering 1 value only does not meet the requirements. Any tool needs to accept input for 2 values: an RGBA value and a background color. It then needs to put the alphaic value over the background and output the result. – Thomas Weller Dec 31 '19 at 12:26
0

I don't know a fully-fledged solution for your case, but Linqpad can help. It's gratis and works on Windows 10.

The following script will convert merge an alpha color with a background color and output the resulting hex code:

// Define input here
var bgcolor = System.Drawing.Color.White;
var alphacolor =  System.Drawing.Color.FromArgb((int)(0.55*255), 0, 0, 0);

// Calculation
float factor = alphacolor.A / 255f;
int red = (int) (bgcolor.R * (1 - factor) + alphacolor.R * factor);
int green = (int) (bgcolor.G * (1 - factor) + alphacolor.G * factor);
int blue = (int) (bgcolor.B * (1 - factor) + alphacolor.B * factor);
var result = System.Drawing.Color.FromArgb(red, green, blue);

// Output as hex
Console.WriteLine($"#{result.A:X2}{result.R:X2}{result.G:X2}{result.B:X2}");

For the given input rgba(0, 0, 0, 0.55) and white background, the result is

#FF727272

Hints: you need to convert decimal values like 0.55 using the formula (int)(<yourvalue>*255). This can only be omitted for the value 0, because the result is 0 as well in this specific case.

| improve this answer | |
-1

You can use this web for your color conversion. But while in rgba you have a value for transparency, in hex the isn't.

| improve this answer | |
  • 1
    That's a nice tool but it doesn't really solve my problem of wanting to compare colors in this case. Is there a way where I can specify the background so that I get the resulting color when transparency gets factored in? – Christian Oct 3 '17 at 9:35
  • 1
    @Christian Add those requirements to your Question. – Basil Bourque Oct 4 '17 at 6:26
-1

This tool should allow you to do this quite well for two colors.

It accepts html color names (e.g. black, white, dark red etc.), hex code (#fff, #000 etc.) and rgba colors (rgba(0.0,0.0,0.0,0.2) etc.)

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.