how to color mask in c

后端 未结 4 912
自闭症患者
自闭症患者 2021-01-26 04:32

how do you color mask a 32 bit unsigned integer for the red, green, and blue values

is it like this? (color_to_be_masked>>8)

4条回答
  •  一向
    一向 (楼主)
    2021-01-26 05:18

    It depends on the format. If you only want to keep the red, and the colors are stored nibble-wise RGBA RRGGBBAA, then color & 0xFF000000 will mask out all the other colors. If you want to know the red value for that same format, (color >> 24) & 0xFF will get it.

提交回复
热议问题