newScreenshot makes an exact copy of the screen buffer, it does not alter the data.
The color and alpha changes because that's how the blend mode works.
Let's say we have pixel A from the background and pixel B from the new image. The "alpha" blend mode does now the following calculation to get the blended pixel C. (I adjusted the math to 0 - 255 instead of 0 - 1. The exact equation is in the
other thread)
Code: Select all
A B A B C
R: 58 70 ( 58 - ( 58 * 140)/255) + ( 70 * 140)/255 64
G: 64 80 --> ( 64 - ( 64 * 140)/255) + ( 80 * 140)/255 = 72
B: 54 91 ( 54 - ( 54 * 140)/255) + ( 91 * 140)/255 74
A: 255 140 (255 - (255 * 140)/255) + (140 * 140)/255 191
The resulting pixel C is not opaque. This is where the transparency comes from.
It looks like OpenGL does indeed just drop the alpha for presentation on the screen. You could do the same with mapPixel to get the desired effect, but it's not very fast.
Code: Select all
img = love.graphics.newScreenshot()
img:mapPixel(
function(x, y, r, g, b, a)
return r, g, b, 255
end
)
We could ask the developers for an extended encode function, but too many options get unlövely and clunky.
Shallow indentations.