How to export PNG screenshot with transparency?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
NewWawe
Prole
Posts: 1
Joined: Sat Oct 20, 2018 1:10 am

How to export PNG screenshot with transparency?

Post 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.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to export PNG screenshot with transparency?

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest