簡體   English   中英

在Lumia Imaging SDK中提取顏色分量-自定義濾鏡

[英]Extracting color components in Lumia Imaging sdk - custom filter

有人可以使用位移運算符在以下語句的右側解釋用於提取顏色分量的計算嗎?

                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

Lumia Imaging SDK使用ARGB顏色格式顯示顏色值。 它將使用8位來編碼每個顏色分量,但是為了簡化/提高效率,它將在單個uint32中存儲和公開所有這四個顏色分量。

這意味着每個顏色分量都按照您看到的順序在int中“布局”:8位用於alpha,8位用於紅色,8位用於綠色和8位用於藍色: ARGB

要提取單個組件,您需要對int進行一些按位運算。 首先,您需要執行and操作以挑選出您感興趣的位( using the & operator ),然后進行按位右移( the >> operator )以將所需的位放入[0,255]范圍。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM