Difference between revisions of "image.new"

From Inspired-Lua Wiki
Jump to navigation Jump to search
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
image.'''new''' is a function that is part of [[:Category:image|image]].
+
image.'''new''' is a function that is part of the [[:Category:image|image]] APIs.
  
 
{{Since|3.0}}
 
{{Since|3.0}}
 +
Updated in ApiLevel 2.3 (OS 3.6).
  
 
== Syntax  ==
 
== Syntax  ==
image.'''new'''(image)  
+
myImage = image.'''new'''(imgData)  
  
 +
For ApiLevel < 2.3 (OS < 3.6) :
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
 
! Parameter !! Type !! Description
 
! Parameter !! Type !! Description
 
|-
 
|-
| <u>image</u> || string || The compressed/encrypted string containing the image header + data (see below)
+
| <u><center>imgData</center></u> || string || The [[TI.Image]]-formatted string
 +
|-
 +
|}
 +
 
 +
For ApiLevel >= 2.3 (OS >= 3.6) :
 +
{| class="wikitable"
 +
|-
 +
! Parameter !! Type !! Description
 +
|-
 +
| <u><center>imgData</center></u> || TI.ResourceHandle || The image resource (as created by the SDK)
 
|-
 
|-
 
|}
 
|}
  
 
== Example  ==
 
== Example  ==
<tt>image.new("\007\000\000\000\008\000\000\000\000\000\000\000\014\000\000\000\016\000\001\000'''alalalalalalalal\000\244\000\244al\000\244\000\244al\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244\000\244al\000\244\000\244\000\244\000\244\000\244alalal\000\244\000\244\000\244alalalalal\000\244alalalalalalalalalal5")</tt>
+
<syntaxhighlight>
 +
-- For ApiLevel < 2.3 (OS < 3.6) :
 +
img = image.new("\002\000\000\000\002\000\000\000\000\000\000\000\004\000\000\000\016\000\001\000\255\255\255\255\255\255\255\255")
 +
 
 +
-- For ApiLevel >= 2.3 (OS >= 3.6) :
 +
img = image.new(_R.IMG.img_1)
 +
 
 +
-- Example from Jim Bauwens:
 +
-- Of course if you have many images you just could use a for loop to do that for every image :
 +
myImages = {}
 +
for img_name, img_resource in pairs(_R.IMG) do
 +
        myImages[img_name] = image.new(img_resource)
 +
end
 +
-- that way you could do
 +
gc:drawImage(myImages.img_1, 10, 10)</syntaxhighlight>
  
 
== See also  ==
 
== See also  ==
 
*[[TI.Image]]
 
*[[TI.Image]]
 +
*[[:Category:image|image functions]]
 
*[[image.copy]]
 
*[[image.copy]]
*[[Category:image]]
 
  
 
<br /><br />
 
<br /><br />
  
 
[[Category:image]]
 
[[Category:image]]

Latest revision as of 17:31, 28 March 2014

image.new is a function that is part of the image APIs.

This has been introduced in TI-Nspire OS 3.0 (Changes).

Updated in ApiLevel 2.3 (OS 3.6).

Syntax

myImage = image.new(imgData)

For ApiLevel < 2.3 (OS < 3.6) :

Parameter Type Description
imgData
string The TI.Image-formatted string

For ApiLevel >= 2.3 (OS >= 3.6) :

Parameter Type Description
imgData
TI.ResourceHandle The image resource (as created by the SDK)

Example

-- For ApiLevel < 2.3 (OS < 3.6) :
img = image.new("\002\000\000\000\002\000\000\000\000\000\000\000\004\000\000\000\016\000\001\000\255\255\255\255\255\255\255\255")

-- For ApiLevel >= 2.3 (OS >= 3.6) :
img = image.new(_R.IMG.img_1)

-- Example from Jim Bauwens: 
-- Of course if you have many images you just could use a for loop to do that for every image :
myImages = {}
for img_name, img_resource in pairs(_R.IMG) do
         myImages[img_name] = image.new(img_resource)
end
-- that way you could do
gc:drawImage(myImages.img_1, 10, 10)

See also