* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: How do you make String Images Ti Nspire Lua  (Read 3999 times)

0 Members and 1 Guest are viewing this topic.

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 282
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
  • Gender: Male
How do you make String Images Ti Nspire Lua
« on: September 27, 2015, 03:31:24 am »
I need to create some images using strings in lua, first off to add support for old lua versions. Also I want to be able to manipulate it easily. I tried searching for tutorials on how to make images, but they all skip over it pretty much as if they assume the reader already knows it. Anyways, can someone tell me in depth how to create lua images. Thank you in advance.


  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18878
  • Post Rating Ratio: +99/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #1 on: September 28, 2015, 03:24:50 am »
Do you mean strings as is strings of characters? Does it mean you would draw images pixel by pixel? Because it seems like it would be slow. In any case, perhaps @Adriweb or @LD Studios might know (and perhaps that could be addressed in Nspire-Lua if it's missing?)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 282
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #2 on: September 28, 2015, 03:30:51 am »
Well yeah. It's the old method of drawing images in lua, and it doesn't seem tooo slow based on some games that use it. And yeah it has something like that but I'm not exactly sure how it works and it also has a 20 byte header where you specify some things about the image, which I don't know how to use. I tried looking at an already made image, but that made me even more confuzzled :(.
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

Offline Adriweb

  • Full User
  • CodeWalrus Supporter
  • *
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 428
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #3 on: September 28, 2015, 03:36:21 am »
The easiest way would be to install TINCS 3.2. It will generate some TI.Image resource in the old string format.
The format itself is known and documented by TI, in fact, as well as here: https://wiki.inspired-lua.org/TI.Image

But yeah, it's slow and annoyingly large, Image resources from 3.6 on are much better.
Supporting old versions seems like a rather moot point, The majority of people have 3.9 if not 4.0 (and some still have 3.6... Earlier ones are very rare)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18878
  • Post Rating Ratio: +99/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #4 on: September 28, 2015, 03:39:14 am »
I know some people still have OS 3.1 because they want as much space as possible and Ndless being reboot-proof.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Adriweb

  • Full User
  • CodeWalrus Supporter
  • *
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 428
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #5 on: September 28, 2015, 03:40:16 am »
Well sure, but supporting a crappy Lua (the one in 3.1) is lots of work, for very few people...
It's kind of like telling webdev now to create this great webapp, but having to support IE6.
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18878
  • Post Rating Ratio: +99/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #6 on: September 28, 2015, 03:43:21 am »
I can agree on that. In any case, though, I think Lua games should at least support 3.6 at the minimum. Didn't Ndless 3.9 require the user to connect his calc to a computer or another TI device via USB in order to be re-installed? At least Ndless 3.6 can be re-installed without an USB cable. That's the main reason why I recently upgraded to 3.6 and not 3.9.1.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Adriweb

  • Full User
  • CodeWalrus Supporter
  • *
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 428
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #7 on: September 28, 2015, 03:45:59 am »
Yeah 3.6 is nice enough, for both native and Lua :)
(even though 3.9 is a bit better for Lua :P)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Offline Streetwalrus

  • Professional slacker
  • Super User
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2903
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #8 on: September 28, 2015, 07:49:00 am »
I use 3.1 because all I care about is ndless and as a dev, I transfer files to my calculator often, and 3.1 is much faster at that than the newer versions.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline LD Studios

  • Full User
  • Join Date: Dec 2014
  • Location:
  • Posts: 136
  • Post Rating Ratio: +10/-0
    • LD Studios
Re: How do you make String Images Ti Nspire Lua
« Reply #9 on: September 28, 2015, 12:12:27 pm »
The easiest way would be to install TINCS 3.2. It will generate some TI.Image resource in the old string format.
The format itself is known and documented by TI, in fact, as well as here: https://wiki.inspired-lua.org/TI.Image

But yeah, it's slow and annoyingly large, Image resources from 3.6 on are much better.
Supporting old versions seems like a rather moot point, The majority of people have 3.9 if not 4.0 (and some still have 3.6... Earlier ones are very rare)

I don't think it's fair to say so plainly that "image resources from 3.6 on are much better", both have their pros and cons,

Benefits of Image Strings
-Image data embedded directly in the code makes transferring code between editors and people much easier
-Images take up significantly less file size
-Image strings can be manipulated to manually reverse images, or replace colors within an image

Benefits of Image Resources
-Images are drawn slightly faster
-Easier organization, and images don't take up large parts of code in the editor

Your argument that image strings are "slow" in comparison is hardly valid, given Jim Bauwen's analysis that:
Code: [Select]
Used image: 320x240 full spectrum gradient

TI-Nspire OS 3.2.4

draw image string: 15.12ms

TI-Nspire OS 3.6

draw image string: 14.08ms
draw image resource: 14.51ms

TI-Nspire OS 3.9

draw image string: 14.16ms
draw image resource: 14.15ms

TI-Nspire OS 4.0

draw image string: 14.26ms
draw image resource: 14.21ms

In OS 3.9 and 4.0, the difference of .01-.05ms seems almost insignificant.

Really it's a matter of preference, but that's why I much prefer image strings, and also why I still use Student Software 3.2



Offline Adriweb

  • Full User
  • CodeWalrus Supporter
  • *
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 428
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #10 on: September 28, 2015, 03:14:31 pm »
Well...

In pre OS 3.6 (or in 3.0-3.2 in non-Lua QnA mode), drawImage was doing a for loop over all the pixels in the image and calling a fillRect of 1x1 px.
In 3.2+ QnA mode (background image private APIs, IIRC) and 3.6+, a call to a blitBuffer (or a similar name, I don't remember exactly, Levak investigated that) is made, much more efficient than the loop at this level.

If you use images extensively (especially if big), you WILL feel the difference between OSes. Benchmarks don't always reflect reality... A simple test is using mViewer GX Creator in API level 1.0 (string images) and in API level 2.3+ (resources images) ;)
I think another big difference is the loading time, in favor of the image resources. But I don't have timings for that.

Quote
-Image data embedded directly in the code makes transferring code between editors and people much easier
Sure, but needing to do that pretty much never happened to me, in the past few years... Use external editors and building scripts :P (However older Luna versions didn't support the new image resource system)

Quote
-Images [strings] take up significantly less file size
For .tns, I'm not sure if this is the case for big images. For smaller sprites, for instance, inlining an image and using an optimizer (like Jim's tool) is probably more efficient than the resource overhead, yes. But in the end, it's the zip compression that compresses everything. So if your png is sufficiently well crushed beforehand, I'm pretty sure image resources can still win (one would have to check)
For .lua, well, there's no comparison since the file is much smaller, only actual code :P

Quote
-Image strings can be manipulated to manually reverse images, or replace colors within an image
True, though these techniques aren't extensively used.

Regarding 3.6 vs. 3.9, the speed difference isn't about images, but drawing speed in general, or at least with individual pixels, see this YouTube video.

And regarding 3.9 vs 4.0, the difference is about the programmer now being able to interact with the Nspire APIs out of the event loop, in the global context/scope, as TI loads the user script after they get ready and not before.
« Last Edit: September 28, 2015, 03:16:25 pm by Adriweb »
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Offline xlibman

  • Omni founder & CW co-founder
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18878
  • Post Rating Ratio: +99/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #11 on: September 28, 2015, 05:18:16 pm »
Just because some techniques aren't regularly used doesn't mean everyone should stop using them, though. That string image thing is interesting by the way. I didn't realize that we could change some image parts on the fly by replacing some string elements.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • Super User
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2903
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #12 on: September 28, 2015, 05:22:10 pm »
Well, you're storing image data in hex so it's pretty easy to change it.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline Adriweb

  • Full User
  • CodeWalrus Supporter
  • *
  • Join Date: Jan 2015
  • Location: France & Canada
  • Posts: 428
  • Post Rating Ratio: +7/-1
    • Adriweb
    • @Adriweb
    • Adriweb
    • @UC-UIrbk5SuaUCvnV6SQvt-Q
    • /u/Adriweb
    • Adriweb
    • TI-Planet.org
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #13 on: September 28, 2015, 06:41:14 pm »
Just because some techniques aren't regularly used doesn't mean everyone should stop using them, though. That string image thing is interesting by the way. I didn't realize that we could change some image parts on the fly by replacing some string elements.
I was rather saying that this is a rare argument as not a lot of people even know about it ; I'm not saying it's not a real argument :)
  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Offline semiprocoder

  • Full User
  • Join Date: May 2015
  • Location:
  • Posts: 282
  • Post Rating Ratio: +2/-0
    • awesommee333
    • 114/11470
  • Gender: Male
Re: How do you make String Images Ti Nspire Lua
« Reply #14 on: September 28, 2015, 08:32:09 pm »
Ok so I will consider that so if it is slow I wont use images but if it is fast enough I will. Also don't understand what flags, padding, the number of bytes between successful lines, and planes per bit  are.
Moreover, how does class extension work, because my program is crashing due to some issues with that. Does it just work like in java or is there something different?
  • Calculators owned: ti nspire, ti 84 plus se
My cemetech username is awesommee333.

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games