简体   繁体   中英

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM