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
Posts: 1
Joined: Sat Oct 20, 2018 1:10 am

How to export PNG screenshot with transparency?

Post by NewWawe » Sat Oct 20, 2018 1:43 am

How to export a PNG screenshot with transparency?

To take a screenshot with LÖVE 0.9.0 you used [] 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 [] 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
Party member
Posts: 1531
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to export PNG screenshot with transparency?

Post by pgimeno » Sat Oct 20, 2018 4:59 am

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.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My repositories - portland (mobile orientation)
The MS-Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests