在Lumia Imaging sdk中提取颜色成分 - 自定义滤镜

时间:2015-04-03 03:42:36

标签: lumia-imaging-sdk nokia-imaging-sdk

有人可以使用位移运算符解释用于在以下语句的右侧提取颜色分量的计算吗?

                uint alpha = (currentPixel & 0xff000000) >> 24; // alpha component

                uint red = (currentPixel & 0x00ff0000) >> 16; // red color component

                uint green = (currentPixel & 0x0000ff00) >> 8; // green color component

                uint blue = currentPixel & 0x000000ff; // blue color component

1 个答案:

答案 0 :(得分:2)

Lumia Imaging SDK使用ARGB color format公开颜色值。它将使用8位来编码每个颜色组件,但为了简单/高效,它将在单个uint32中存储和显示它们中的所有四个。

这意味着每个颜色组件按照您看到的顺序在int中“布局”:8位为alpha,8位为红色,8位为绿色,8位为蓝色: ARGB

要提取单个组件,您需要对int执行一些按位操作。首先,你需要做一个和操作来挑出你感兴趣的位(using the & operator),然后你做一个按位右移(the >> operator)来得到你想要的位到[0, 255]范围。

相关问题