cnavarreteliz
cnavarreteliz

Reputation: 139

Android - Convert ARGB Color to RGB

I'm trying to get the rgb value of a color with alpha, meaning make it full opaque with different red, green and blue values.

For example,

Color.argb(204, 40, 40, 40) // I have this color
Color.rgb(48, 48, 48) // I expect this value

I've tried converting argb to HEX, and after HEX to rgb, but doesn't work.

Upvotes: 3

Views: 4361

Answers (1)

Eugen Pechanec
Eugen Pechanec

Reputation: 38243

Your input is a translucent color and you expect a slightly brighter output. That can be achieved by overlaying your input over white.

support-v4 library contains ColorUtils.compositeColors which does what you need:

final int input = Color.argb(204, 40, 40, 40);
final int output = ColorUtils.compositeColors(input, Color.WHITE);

Upvotes: 7

Related Questions