TI.Image

From Hackspire
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 : [image WIDTH]\000\000\000\[Image HEIGHT]\000\000\000\000\000\000\000\[image Data WIDTH]\000\000\000\[image Depth]\000\001\000

[image Data WIDTH] is the width of one data row (normally 2*[image WIDTH]) 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. The data is in bitmap form, 2 bytes for each pixel.

2 bytes for each pixel means 16 bits, but we only use 15 bit for the colors, 5 for each color: S - RRRRR - GGGGG - BBBBB If S is 0, the pixel is NOT shown. If it is one it is shown. Example : 1111010111100001

To convert this to a format that the nspire understands we have to split the number in two (2 * 8 bit) and convert both binary numbers to decimal:

11110101 - 11100001
   ||         ||
   \/         \/
  245         225

This becomes \225\245 in the data list.

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

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

Jimbauwens made a image previewer. You have to paste the image data, and it will display it.