![](/img/trans.png)
[英]How can I add alpha channel to three channel image using Java OpenCV?
[英]How can the alpha channel be -1?
我想知道單個像素的alpha通道如何為-1? 我正在瀏覽PNG圖像的每個像素(加載到緩沖圖像,ARGB類型)。 許多alpha值是-1(其他值大於零) - 這怎么可能? 該值不應介於0到255之間嗎? 代碼如下。 謝謝你的提示!
// imagine some great loop for x and y before this code
int a = (scaledImage.getRGB(x, y) & 0xff000000) >> 24; // kill all bits except for the first 8, shift 24 to the right to get them
System.out.println("" + a);
您正遇到標志擴展問題。 請使用unsigned shift operator >>>
。
如果將其視為unsigned int,則為-1 = 0xFF = 255.這只是解釋alpha通道的255值的另一種方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.