Difference between revisions of "RenderTarget:save"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2016.08<br/>
'''<translate>Available since</translate>:''' Gideros 2016.08<br/>
+
'''Class:''' [[RenderTarget]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/RenderTarget|RenderTarget]]<br/>
+
 
=== <translate>Description</translate> ===
+
=== Description ===
<translate>save contents of RenderTarget as image</translate>
+
Saves content of RenderTarget as image.
<source lang="lua">
+
<syntaxhighlight lang="lua">
RenderTarget:save(filename,x,y,width,height)
+
RenderTarget:save(filename,x,y,width,height)
</source>
+
</syntaxhighlight>
=== <translate>Parameters</translate> ===
+
 
'''filename''': (string) <translate>filename and path to store file, like |D|image.png</translate> <br/>
+
=== Parameters ===
'''x''': (number) <translate>x coordinate from where to start image</translate> '''optional'''<br/>
+
'''filename''': (string) filename and path to store file, like |D|image.png<br/>
'''y''': (number) <translate>y coordinate from where to start image</translate> '''optional'''<br/>
+
'''x''': (number) x coordinate from where to start image '''optional'''<br/>
'''width''': (number) <translate>width of the image to save</translate> '''optional'''<br/>
+
'''y''': (number) y coordinate from where to start image '''optional'''<br/>
'''height''': (number) <translate>height of the image to save</translate> '''optional'''<br/>
+
'''width''': (number) width of the image to save '''optional'''<br/>
 +
'''height''': (number) height of the image to save '''optional'''<br/>
 +
 
 +
=== Example ===
 +
<syntaxhighlight lang="lua">
 +
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
 +
</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