Lokie
Lokie

Reputation: 23

Convert ARGB to RGB and get the same color

I get #AARRGGBB color from

int  getColor=bitmap.getPixel()

(Bitmap is ARGB_8888)

As example, getColor value is: #20000000(light grey) I need to get same color in #RRGGBB, something like #BDBDBD(light grey).

How can I do this?

Upvotes: 2

Views: 2915

Answers (2)

Sami Kuhmonen
Sami Kuhmonen

Reputation: 31143

If you want the color that would appear when placing that color on top of white you have to blend it. Since alpha is 0x20 you multiply that color by 0x20 and white by 0xff-0x20 and add them up.

Of course do this to R, G and B separately.

Upvotes: 1

Martin G
Martin G

Reputation: 329

Have a look here: how to change the color of certain pixels in bitmap android

In your case it would be

  for (int i=0; i<myBitmap.getWidth()*5; i++)
      pixels[i] = 0xFFBDBDBD;

The 32 bit integer starts with 0xFF=255 for the alpha value to provide 100% opacity.

Upvotes: 0

Related Questions