Difference between revisions of "RenderTarget:save"
From GiderosMobile
(added example) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Saves content of RenderTarget as image. | Saves content of RenderTarget as image. | ||
− | < | + | <syntaxhighlight lang="lua"> |
RenderTarget:save(filename,x,y,width,height) | RenderTarget:save(filename,x,y,width,height) | ||
− | </ | + | </syntaxhighlight> |
=== Parameters === | === Parameters === | ||
Line 17: | Line 17: | ||
=== Example === | === Example === | ||
− | < | + | <syntaxhighlight lang="lua"> |
local source = Bitmap.new(Texture.new("gfx/collectibles/coin_20_x01.png", true)) | local source = Bitmap.new(Texture.new("gfx/collectibles/coin_20_x01.png", true)) | ||
local rt = RenderTarget.new(source:getWidth(), source:getHeight()) | local rt = RenderTarget.new(source:getWidth(), source:getHeight()) | ||
Line 26: | Line 26: | ||
rt:draw(source) | rt:draw(source) | ||
rt:save("C:\\tmp\\coin.png") -- this is on windows 10 | rt:save("C:\\tmp\\coin.png") -- this is on windows 10 | ||
− | </ | + | </syntaxhighlight> |
{{RenderTarget}} | {{RenderTarget}} |
Latest revision as of 14:31, 13 July 2023
Available since: Gideros 2016.08
Class: RenderTarget
Description
Saves content of RenderTarget as image.
RenderTarget:save(filename,x,y,width,height)
Parameters
filename: (string) filename and path to store file, like |D|image.png
x: (number) x coordinate from where to start image optional
y: (number) y coordinate from where to start image optional
width: (number) width of the image to save optional
height: (number) height of the image to save optional
Example
local source = Bitmap.new(Texture.new("gfx/collectibles/coin_20_x01.png", true))
local rt = RenderTarget.new(source:getWidth(), source:getHeight())
local bmp = Bitmap.new(rt)
bmp:setPosition(200, 0)
stage:addChild(bmp)
source:setColorTransform(0.5, 0.5, 0, 2)
rt:draw(source)
rt:save("C:\\tmp\\coin.png") -- this is on windows 10