TI.Image

From Hackspire
Revision as of 09:34, 22 April 2011 by AdRiWeB (talk | contribs) (→‎Header)
Jump to navigation Jump to search

The TI.Image format is a type of image used in several places in the Nspire documents, such as Lua scripts.

The format is some form of bitmap, with almost no compression at all.

The examples here, as the encoded strings visible in .lua files sometimes show letters and symbols instead of expected "\xxx" characters. This is because the "\xxx" is actually a representation of a non-printable character, and when, by chance, the character is printable the editor displays its value, which can be a letter, a symbol etc.

Header

The format has a header specifying the total buffer length. The header is 20 decimal numbers long.

Example header : .\000\000\000\018\000\000\000\000\000\000\000\092\000\000\000\016\000\001\000

We currently know that it is encoded as follow : \xxx\000\000\000\[Image HEIGHT]\000\000\000\000\000\000\000\[image WIDTH]\000\000\000\[image Depth]\000\001\000

The numbers must be between 000 and 255 (00 to FF in hex)

We also know that when we change the second triplet of number (in the example above, it would be the first \000 sequence, because the first characters in the string is printable, as a "." (dot)) from \000 to \001, the image becomes x-repeated and y-shifted for each iteration.

Some modifications on other triplets can cause some buffer overflow and segmentation faults errors.

Data

The image data comes directly after the header, and is written in the same pattern.

[image data] can be, for example, \011\022\033\044\055\066\077\088


Let's consider that [image height] is \004 and [image width] is \002. Then the image looks like this: (each number being a pixel)

\011 \022
\033 \044
\055 \066
\077 \088

Each number actually represents a color. We are still documenting the color map.

Extra compression: As said previously, numbers which are displayable in the ascii table (on the nspire) are replaced with the corresponding character. \105 is for example replaced with 'i'. This is not necessary though.

External Links

User:AdRiWeB made a video showing some direct manipulations of the TI-Image, in order to understand better how the format in general.

User:jimbauwens made a image previewer. You have to paste the image data, and it will display it. Currently only shows the image in grayscale.