Page 1 of 1

How to export PNG screenshot with transparency?

Posted: Sat Oct 20, 2018 1:43 am
by NewWawe
How to export a PNG screenshot with transparency?

To take a screenshot with LÖVE 0.9.0 you used [love.graphics.newScreenshot] and set the argument [copyAlpha] to true, and a PNG would be rendered with transparency based on the alpha applied on draw().

LÖVE 0.11.0 replaced the function with [love.graphics.captureScreenshot] but removed the [copyAlpha] argument and now render weird opaque PNGs compared to the older version.

To make matters worse, the older function tested on 0.9.0 don't works properly with Windows 10 rendering a PNG with thumbnail but a blank transparent image. It is fine on Windows 7.

Re: How to export PNG screenshot with transparency?

Posted: Sat Oct 20, 2018 4:59 am
by pgimeno
You can try drawing to a canvas instead of the screen, and saving via Canvas:newImageData.

Note however that OpenGL does not support proper alpha compositing without a custom shader, so if you use normal blending mode, the PNG you will obtain will have premultiplied alpha, which is not supported by PNG. You can try to "unmultiply" it; GIMP 2.10 has such a tool as a GEGL operation, but due to having just 256 levels, there will be quality loss.