You are here: Writing Lua Scripts > Managing Images

Managing Images

To insert an image into a script application, follow these steps.

Add an Image to Resources

1. Click the Resource tab.
2. Click the button.
3. Click on an image file name.
4. Click Open.
5. Accept the default image name or rename the image by typing a new name into the box. (Ex: newimage)
6. Click OK.

Note: You will see the image thumbnail in the bottom-right corner of your screen. Your image file name will appear in a list of images at the bottom-left of your screen.

7. Right-click an image name to Rename, Copy Name, Preview, or Remove the image. You may also click the button to remove an image.

 

Add Multiple Images to Resources

1. Click the Resource tab.
2. Click the button.
3. Select Comma Separated Values (*.csv) from the Files of Type menu.
4. Select your .csv file.

Note: The .csv format consists of two comma-separated columns. The first column is the local name of the image resource used in the code. The second column is the absolute path to the image on the current system.

Example for Windows:

bridge,C:\images\bridge.jpg

house,C:\images\house.jpg

5. Click Open.
6. Right-click an image name to Rename, Copy Name, Preview, or Remove the image. You may also click the button to remove an image.

 

Create a Script to Call Up an Image

1. Type a script in the script line box as follows:

myimage = image.new(_R.IMG.img_1)

function on.paint (gc)

gc:drawImage (myimage, 30, 30)

end

Note:Replace img_1 (above) with the name of your image.

2. Click Set Script to save the script. You will see your image in the Document Preview screen.
3. Click Focus Script to set the focus to the page in the document where you want to attach the script application.

Note: A TI-Nspire document sets the focus to the page; A PublishView™ document sets the focus to the frame on the page.

 

Create a Script to Call Up Multiple Images

1. Type a script in the script line box as follows:

myimg = { }

for name, data in pairs (_R.IMG)

myimg [name] = image.new(data)

end

function on.paint (gc)

gc:drawImage (myimg[imagename], 30, 30)

end

2. Click Set Script to save the script. You will see your image in the Document Preview screen.
3. Click Focus Script to set the focus to the page in the document where you want to attach the script application.

Note: A TI-Nspire document sets the focus to the page; A PublishView™ document sets the focus to the frame on the page.


 

© 2006 - 2015 Texas Instruments Incorporated