java - 使用异或将颜色与像素分开

标签 java colors xor

我正在参加普林斯顿挑战赛,在下一页 http://www.cs.princeton.edu/courses/archive/fall10/cos126/assignments/lfsr.html 上遇到了我不明白的一行内容。 ,该线位于管道的第一张图片的下方。

For each pixel (x, y), in the order (0, 0), (0, 1), (0, 2), ..., extract the red, green, and blue components of the color (each component is an integer between 0 and 255).

Then, xor the red component with 8 newly generated bits. Do the same for the green (using another 8 newly generated bits) and, finally, the blue.

Create a new color using the result of the xor operations, and set the pixel to that color.

我不太确定在 3 次异或运算后如何创建新颜色,因为异或运算只会产生 true 或 false 值。

最佳答案

不,您将一个 8 位 颜色分量值与另一个 8 位 值进行异或,大致如下:

    1010 1010
xor 1111 0000
    ---- ----
    0101 1010

虽然单个xor对两个位进行操作以产生另一个位,但对多位值执行该操作意味着依次对每个位执行该操作。

另请参阅this answer .

关于java - 使用异或将颜色与像素分开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6185029/

相关文章:

java - 如何获取 Canvas 的当前位图?

javax.jms.JMSException : No ManagedConnections available within configured blocking timeout

java - 我可以为我的所有实体覆盖 singleTableEntityPersister 吗?

python - 将 RGB 颜色转换为 RGBA 的 Plotly 函数? (Python)

c++ - 为什么我收到 'operator^' 不匹配的错误

c - 如何将两个字节值合并为一个?

api - Swagger API 文档 XOR

java - 玩框架认证,比如htaccess

ios - 是否可以更改 Apple Map 颜色?

iphone - 在 iPhone 上采用 RGB 颜色并使用 UIColor 对其进行标准化