Home Deutsch     LTF Forum bei www.RPKLaser.de
Description of the Laserimage Transfer Format (LTF)

C/C++, Pascal Code for read/write will follow

(c) Rolf Peter Kolpack & Rainer Moor

Sample listing to read an LTF file in Pascal:

{---------------------------------------------------------}
Procedure read_header;
Begin
  read_header;
end;
{---------------------------------------------------------}
Procedure read_tags;
Begin
  Repeat
    TagId = read_byte;
    TagLen = read_byte;
    if TagLen=255 then Taglen := read_longint;               (DWord  in Delphi)
    Case Tagid of
       TagColorTable  :read_colortable;                      {1}
       TagHersteller  :read_manufacturer;                    {2}
       TagImageName:  :read_framename;                       {3}
       TagSetPPS      :read_pps;                             {4}
       TagImage1      :read_tagimage1;                       {10}
     Else Tag_skip_unknown
    end;
  until Tagid=TagEnd;                                        {0=End}
{---------------------------------------------------------}
Begin                                                        {Start}
  read_header;
  read_tags;
end.
{------------------------ End Pascal----------------------}

Definition of basic types
Sample listing to read an LTF file in C:
read_header( LTF);
do {
   TagId = fgetU8( LTF);
   TagLen = fgetU8( LTF);
   if( TagLen == 255) {
     TagLen = fgetU32( LTF);
   }
   switch( TagId)
   {
   case TagEnd:
     break;
   case TagColorTable:
     read_TagColorTable();
     break;
   case TagManufacturer:
     read_TagManufacturer();
     break;
   case TagImageName:
     read_TagImageName();
     break;
   case TagSetPPS:
     read_TagSetPPS();
     break;
   case TagImage1:
     read_TagImage1();
     break;
   default:
     /* unknown, so skip... */
     getbytes( LTF, TagLen);
     break;
   }
} while( TagId != TagEnd);

Definition of basic types
Type Description - order
U8 8 Bit unsigned, 0..255
S8 8 Bit signed, -128..127
U16 16 Bit unsigned, 0..65535 (2 Bytes MSB/LSB)
S16 16 Bit signed, -32768..32767 (2 Bytes MSB/LSB)
U32 32 Bit unsigned (4 Bytes UpperMSB/UpperLSB/LowerMSB/LowerLSB)
S32 32 Bit signed (4 Bytes UpperMSB/UpperLSB/LowerMSB/LowerLSB)
STRING ASCII-String in C-Format (zero terminated)

Description LTF-Header (16 Bytes)
ByteOffset Len/Type Description
0 3 - char "L","T","F" - ASCII-"LTF"
3 U8 Version number (aktualy 0)
4 U32 Total_Tags: number of Tags in this file( only for info)
8 U32 TagImage1count: number of TagImage1 in this file
12 U32 reserved, must be zero !

Each datablock has an identifier(TagID) and a len (TagLen)
so we can skip unknown or unsupported tags easy

Description LTF-Tag struct:
ByteOffset Len/Type Description
0 U8 TagId: Type of Tag's (example, 0=EndTag)
1 U8 TagSLen: Len in bytes of Tagdata(0..254),if = 255 then the following entry
2 U32 TagLLen: Len in bytes of Tagdata. <-- only if TagSLen = 255
2/6 ?? TagData

Description LTF-TagEnd(0)
ByteOffset Len/Type Value - Description
0 U8 TagId = 0
1 U8 TagSLen = 0

Description LTF-TagColorTable(1)
ByteOffset Len/Type Value - Description
0 U8 TagId = 1
1 U8 TagSLen = 255
2 U32 TagLLen: Len of following data in bytes (2 + ColTabsize * 3).
6 U16 ColTabsize: number of entries (1..65535)
8.. U8 Red 0..255
9.. U8 Green 0..255
10.. U8 Blue 0..255

Description LTF-TagManufacturer(2)
ByteOffset Len/Type Value - Description
0 U8 TagId = 2
1 U8 TagSLen: Len of following data in bytes(max.254)
2 STRING Manufacturer

Description LTF-TagImageName(3)
ByteOffset Len/Type Value - Description
0 U8 TagId = 3
1 U8 TagSLen: Len of following data in bytes(max.254)
2 U16 Frame_nr: Number of Image.
4 STRING ImageName

Description LTF-TagSetPPS(4)
ByteOffset Len/Type Value - Description
0 U8 TagId = 4
1 U8 TagSLen = 4
2 U32 PPS: Points per Second

Description LTF-TagImage1(10)
ByteOffset Len/Type Value - Description
0 U8 TagId = 10
1 U8 TagSLen = 255
2 U32 TagLLen: Len of following data in bytes.
6 U16 Image_Nr: Imagenumber in this file (0...65535)
8 U16 Points_Total: number of points (1...65535) in this Image.
10 U8 Frame_Repeat: (0 = once, can be ignored but should not)
11 U8 Pointtype (see below)
12.. LTF-Point LTF-Point[Points_Total]

The Pointtypes comes in pairs with Z and without Z.
On Bit 0 we can test if there is a Z value (Bit 0=0)

PT_XYZ8_PAL
PT_XY8_PAL
PT_XYZ12_PAL
PT_XY12_PAL
PT_XYZ16_PAL
PT_XY16_PAL
PT_XYZ12_RGB5
PT_XY12_RGB5
PT_XYZ16_RGB5
PT_XY16_RGB5
PT_XYZ16_RGB8
PT_XY16_RGB8
PT_XYZ32_RGB8
PT_XY32_RGB8

Description LTF-Punkt Type 0, Len 4 Bytes
PT_XYZ8_PAL
ByteOffset Len Description
0 S8 X, Bit7 is signbit
1 S8 Y, Bit7 is signbit
2 S8 Z, Bit7 is signbit
3 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 colortablenumber 0..127

Description LTF-Punkt Type 1, Len 3 Bytes
PT_XY8_PAL
ByteOffset Len Description
0 S8 X, Bit7 is signbit
1 S8 Y, Bit7 is signbit
2 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 colortablenumber 0..127

Description LTF-Punkt Type 2, Len 6 Bytes
PT_XYZ12_PAL
ByteOffset Len Description
0 S8 X, upper 8 Bit of 12, Bit11 is signbit
1 S8 Y, upper 8 Bit of 12, Bit11 is signbit
2 S8 Z, upper 8 Bit of 12, Bit11 is signbit
3 U8 Bits 7..4 lower 4 Bit of X, Bits 3..0 lower 4 Bit of Y.
4 U8 Bits 7..4 lower 4 Bit of Z, Bits 3..0 are reserved and must be zero !
5 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 colortablenumber 0..127

Description LTF-Punkt Type 3, Len 4 Bytes
PT_XY12_PAL
ByteOffset Len Description
0 S8 X, upper 8 Bit of 12, Bit11 is signbit
1 S8 Y, upper 8 Bit of 12, Bit11 is signbit
2 U8 Bits 7..4 lower 4 Bit of X, Bits 3..0 lower 4 Bit of Y.
3 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 colortablenumber 0..127

Description LTF-Punkt Type 4, Len 8 Bytes
PT_XYZ16_PAL
ByteOffset Len Description
0 S16 X, Bit15 is signbit
2 S16 Y, Bit15 is signbit
4 S16 Z, Bit15 is signbit
6 U16 Attribut: Bit 15=1=Blank(0=Light)
Bit's 14..12 are reserved and must be zero !
Bit's 11..0 colortablenumber 0..4095

Description LTF-Punkt Type 5, Len 6 Bytes
PT_XY16_PAL
ByteOffset Len Description
0 S16 X, Bit15 is signbit
2 S16 Y, Bit15 is signbit
4 U16 Attribut: Bit 15=1=Blank(0=Light)
Bit's 14..12 are reserved and must be zero !
Bit's 11..0 colortablenumber 0..4095

Description LTF-Punkt Type 6, Len 6 Bytes
PT_XYZ12_RGB5
ByteOffset Len Description
0 S8 X, upper 8 Bit of 12, Bit11 is signbit
1 S8 Y, upper 8 Bit of 12, Bit11 is signbit
2 U8 Bits 7..4 lower 4 Bit of X, Bits 3..0 lower 4 Bit of Y.
4 U8 Bits 7..4 lower 4 Bit of Z, Bits 3..0 are reserved and must be zero !
6 U16 Attribut: Bit 15=1=Blank(0=Light)
Bit's 14..12 are reserved and must be zero !
Bit's 11..0 colortablenumber 0..4095

Description LTF-Punkt Type 7, Len 5 Bytes
PT_XY12_RGB5
ByteOffset Len Description
0 S8 X-Koord, upper 8 Bit of 12, Bit11 is signbit
1 S8 Y-Koord, upper 8 Bit of 12, Bit11 is signbit
2 U8 Bits 7..4 lower 4 Bit of X, Bits 3..0 lower 4 Bit of Y.
4 U16 Attribut: Bit 15=1=Blank(0=Light)
Bit's 14..12 are reserved and must be zero !
Bit's 11..0 colortablenumber 0..4095

Description LTF-Punkt Type 8, Len 8 Bytes
PT_XYZ16_RGB5
ByteOffset Len Description
0 S16 X, Bit15 is signbit
2 S16 Y, Bit15 is signbit
4 S16 Z, Bit15 is signbit
6 U16 Attribut: Bit 15=1=Blank(0=Light)
then 3 * 5 Bits Red,Green,Blue

Description LTF-Punkt Type 9, Len 6 Bytes
PT_XY16_RGB5
ByteOffset Len Description
0 S16 X, Bit15 is signbit
2 S16 Y, Bit15 is signbit
6 U16 Attribut: Bit 15=1=Blank(0=Light)
then 3 * 5 Bits Red,Green,Blue

Description LTF-Punkt Type 10, Len 10 Bytes
PT_XYZ16_RGB8
ByteOffset Len Description
0 S16 X, Bit15 is signbit
2 S16 Y, Bit15 is signbit
4 S16 Z, Bit15 is signbit
6 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 are reserved and must be zero !
7 U8 Red 0..255
8 U8 Green 0..255
9 U8 Blue 0..255

Description LTF-Punkt Type 11, Len 8 Bytes
PT_XY16_RGB8
ByteOffset Len Description
0 S16 X, Bit15 is signbit
2 S16 Y, Bit15 is signbit
4 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 are reserved and must be zero !
5 U8 Red 0..255
6 U8 Green 0..255
7 U8 Blue 0..255

Description LTF-Punkt Type 12, Len 16 Bytes
PT_XYZ32_RGB8
ByteOffset Len Description
0 S32 X, Bit31 is signbit
4 S32 Y, Bit31 is signbit
8 S32 Z, Bit31 is signbit
12 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 are reserved and must be zero !
13 U8 Red 0..255
14 U8 Green 0..255
15 U8 Blue 0..255

Description LTF-Punkt Type 13, Len 12 Bytes
PT_XY32_RGB8
ByteOffset Len Description
0 S32 X, Bit31 is signbit
4 S32 Y, Bit31 is signbit
8 U8 Attribut: Bit 7=1=Blank(0=Light)
Bit's 6..0 are reserved and must be zero !
9 U8 Red 0..255
10 U8 Green 0..255
11 U8 Blue 0..255

The LTF standard colortable
Colornumber Red Green Blue
0 255 0 0
1 255 16 0
2 255 32 0
3 255 48 0
4 255 64 0
5 255 80 0
6 255 96 0
7 255 112 0
8 255 128 0
9 255 144 0
10 255 160 0
11 255 176 0
12 255 192 0
13 255 208 0
14 255 224 0
15 255 240 0
16 255 255 0
17 224 255 0
18 192 255 0
19 160 255 0
20 128 255 0
21 96 255 0
22 64 255 0
23 32 255 0
24 0 255 0
25 0 255 32
26 0 255 64
27 0 255 96
28 0 255 128
29 0 255 160
30 0 255 192
31 0 255 224
32 0 130 255
33 0 114 255
34 0 104 255
35 10 96 255
36 0 82 255
37 0 74 255
38 0 64 255
39 0 32 255
40 0 0 255
41 32 0 255
42 64 0 255
43 96 0 255
44 128 0 255
45 160 0 255
46 192 0 255
47 224 0 255
48 255 0 255
49 255 32 255
50 255 64 255
51 255 96 255
52 255 128 255
53 255 160 255
54 255 192 255
55 255 224 255
56 255 255 255
57 255 224 224
58 255 255 255
59 255 160 160
60 255 128 128
61 255 96 96
62 255 64 64
63 255 32 32
63 255 32 32
64..4095 255 32 32
28_9_00