Join us on Discord!
You can help CodeWalrus stay online by donating here.

How do you make String Images Ti Nspire Lua

Started by semiprocoder, September 27, 2015, 03:31:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

semiprocoder

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.

Dream of Omnimaga

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-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

semiprocoder

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.

Adriweb

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

Dream of Omnimaga

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-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Adriweb

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

Dream of Omnimaga

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-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Adriweb

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

novenary

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.

LD Studios

Quote from: Adriweb 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)

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:

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



Adriweb

#10
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.
  • 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

Dream of Omnimaga

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-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

novenary

Well, you're storing image data in hex so it's pretty easy to change it.

Adriweb

Quote from: DJ Omnimaga 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.
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

semiprocoder

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.

Powered by EzPortal