I’m working on processing and I’d like to recreate on low level code the function
blend lightest.
I saw in documentation that C = max(A * factor, B)
Cis the returned colorAis the sourceBis the image to mix with
I’ve seen on web that the factor specified is based on the alpha component of the source pixel, which is represented by the first 8 bits ( from the left ) of the 32-bit integer representing the pixel color. These leftmost bits are also referred to as the highest bits.
Source: this book, page 464
What should i think of it?
This is my code of that part:
for (int y = 0; y < capWidth * capHeight; y++) {
int factor = (pixels[y] >> 24) & 0xFF;
pixels[y] = max(pixels[y] * factor, previousFrame.pixels[y]);
}
That doesn’t work, any help?
For each color: C = A(a/255) + B(1-(a/255)), where:
A is the foreground value,
B is the background value,
C is the resultant value, and
a is the alpha component.
This is per the alpha blending wiki page: http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending