W3cubDocs

/LÖVE

love.graphics.newScreenshot

Creates a screenshot and returns the image data.

This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!

Function

Synopsis

screenshot = love.graphics.newScreenshot( )

Arguments

None.

Returns

ImageData screenshot
The image data of the screenshot.

Function

Available since LÖVE 0.9.0
This variant is not supported in earlier versions.

Synopsis

screenshot = love.graphics.newScreenshot( copyAlpha )

Arguments

boolean copyAlpha (false)
Whether to include the screen's alpha channel in the ImageData. If false, the screenshot will be fully opaque.

Returns

ImageData screenshot
The image data of the screenshot.

Examples

Create a new screenshot and write it to the save directory.

function love.load()
    love.filesystem.setIdentity('screenshot_example');
end
 
function love.keypressed()
    local screenshot = love.graphics.newScreenshot();
    screenshot:encode('png', os.time() .. '.png');
end

See Also


© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.newScreenshot