Difference between revisions of "love.graphics.newScreenshot"

(Added new 0.9.0 variant)
(Updated for 11.0)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{oldin|[[11.0]]|110|type=function|text=It has been replaced by [[love.graphics.captureScreenshot]]}}
 
Creates a screenshot and returns the image data.
 
Creates a screenshot and returns the image data.
 
{{newobjectnotice}}
 
{{newobjectnotice}}
Line 22: Line 23:
 
=== Returns ===
 
=== Returns ===
 
{{param|ImageData|screenshot|The image data of the screenshot.}}
 
{{param|ImageData|screenshot|The image data of the screenshot.}}
 +
 +
== Examples ==
 +
Create a new screenshot and write it to the save directory.
 +
<source lang="lua">
 +
function love.load()
 +
    love.filesystem.setIdentity('screenshot_example');
 +
end
 +
 +
function love.keypressed()
 +
    local screenshot = love.graphics.newScreenshot();
 +
    screenshot:encode('png', os.time() .. '.png');
 +
end
 +
</source>
  
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]
 +
* [[Constructs::ImageData]]
 
* [[ImageData:encode]]
 
* [[ImageData:encode]]
 
[[Category:Functions]]
 
[[Category:Functions]]

Latest revision as of 20:11, 1 April 2018

Removed in LÖVE 11.0
It has been replaced by love.graphics.captureScreenshot.

Creates a screenshot and returns the image data.

O.png 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


Other Languages