tga2viff(1)

PROGRAM
tga2viff - Converts a TGA image to a viff image.

SYNTAX

tga2viff

-i  input Truevision image file

-o  resulting output image (viff file)

[-e]
    Number of bytes to skip over when reading the file

[-V]
    Gives the version for tga2viff

[-U]
    Gives the usage for tga2viff

[-P]
    Prompts for command line options

[-A [file1]]
    Creates the answer file called tga2viff.ans or file1

[-a [file1]]
    Uses tga2viff.ans or file1 as the answer file

DESCRIPTION
The purpose of this routine is to convert tga image into viff image The tga format is described below. the viff format can be read in the KHOROS manual.

Only the tga image 2 and 3 (respectively Uncompressed True-Color Image and Uncompressed Black and White Image) are converted.

The Extension Area, the Developer Fields and the TGA Footer are not processed yet, but will be if anybody needs it.

    This section defines the file formats recommended for storing images for the AT&T Truevision product family. These formats should be used by all software developed for the Truevision product family. This standard is recommended since it allows software products to be compatible with our telecommunications and imaging software.

    Truevision Inc. has currently defined eleventypes of data files.

    The File Format is the following one:

   BYTE ||| FIELD NAME |
__________________________________________
------------------------------------------ -----
     0 ||| I.D. Length | |
__________________________________________ |
------------------------------------------ |
     1 ||| Color Map Type | |
__________________________________________ |
------------------------------------------ | T G A File
     2 ||| Image Type | | (Fixed Length)
__________________________________________ |
------------------------------------------ |-----
     3 ||| Color Map Specification | |
        ||| ( 5 bytes ) | |
__________________________________________ |
------------------------------------------ |
     8 ||| Image Specification | |
        ||| ( 10 bytes) | |
__________________________________________ |
------------------------------------------ ----|
Variable||| Image I.D. | | Image /
__________________________________________ | Color Map
------------------------------------------ | DATA
Variable||| Color Map Data | | Variable
__________________________________________ | Length
------------------------------------------ |
Variable||| Image Data | |
__________________________________________ |
------------------------------------------ |
Variable||| Developer Fields | |
__________________________________________ |
------------------------------------------ |
Variable||| Developer Directory | |
        ||| | |
__________________________________________ |
------------------------------------------ ----|
    0 ||| Extension Size |Short |
------------------------------------------ |
    2 ||| Author Name |ASCII |
------------------------------------------ |
   43 ||| Authors Comments |ASCII |
------------------------------------------ |
  367 ||| Date / Time Stamp |Shorts |
------------------------------------------ |
  379 ||| Job Name / ID |Short |
------------------------------------------ |
  420 ||| Job Time |Shorts |
------------------------------------------ |
  426 ||| Software I.D. |ASCII |
------------------------------------------ | Extension Area
  467 ||| Software Version |3 Bytes| Variable
------------------------------------------ | Length
  470 ||| Key Color |Long | (Optional)
------------------------------------------ |-----
  474 ||| Pixel Aspect Ratio |Shorts |
------------------------------------------ |
  478 ||| Gamma Value |ASCII | only for
------------------------------------------ | version 2.0
  482 ||| Color Correction Offset |long | and +
------------------------------------------ |
  486 ||| Postage Stamp Offset |long |
------------------------------------------ |
  490 ||| Scan Line Offset |Long |
------------------------------------------ |
  494 ||| Attributes Type |Byte |
__________________________________________ |
------------------------------------------ |
Variable||| Scan Line Table | |
------------------------------------------ |
Variable||| Postage Stamp Image | |
------------------------------------------ |
2 kbytes||| Color Correction Table | |
__________________________________________ ____|
------------------------------------------ ----|
    0 ||| Extension Area Offset |Long | T G A File
------------------------------------------ | Footer
    4 ||| Developper Directory Offs |Long | Fixed Length
------------------------------------------ |-----
    8 ||| Extension / Order Signatu |ASCII |
-------------------------------------------------- (Optional)

Description of the different Usefull fields

1   Field 1:

2   Number of characters in IDENTIFICATION FIELD (1 byte). This field identifies the number of bytes in field 6, the image identification field. The maximum number of characters is 255. A value of 0 indicates that no identification field is included.

1   Field 2:

2   Color_Map Type (1 byte).

1   Field 3:

2   Image Type Code (1 byte).

1   Field 4:

2   Color_Map Specification (5 bytes).

1   Field 4.1:

2   Color Map Origin (2 bytes). Index of first color_map entry.

1   Field 4.2:

2   Color Map Length (2 bytes). Number of color_map entries.

1   Field 4.3:

2   Color Map Entry Size (1 byte). Number of bits in color_map entry.

1   Field 5:

2   Image Specification (10 bytes).

1   Field 5.1:

2   X-origin of image (2 bytes). 5.1 and 5.2 specify the lower left corner of the image.

1   Field 5.2:

2   (2 bytes). See previous subfield.

1   Field 5.3:

2   (2 bytes). Width of the image in pixels.

2   Field 5.4:

2   (2 bytes). Height of the image in pixels.

1   Field 5.5:

2   Image Pixel Size (1 byte). Number of bits in a stored pixel.

1   Field 5.6:

2   Image Descriptor Byte (1byte).

3   Bit 3-0: Number of attribute bits associated with each pixel.

3   Bit 4 : Reserved. Must be 0.

3   Bit 5 : Screen origin bit:

4   0 _ Origin in lower left-hand corner

4   1 _ Origin in upper left-hand corner

4   Must be set to 0 for Truevision images.

3   Bit 7-6: Data storage Interleaving Flag

4   00 - Non Interleaved.

4   01 Two way interleaving.

4   10 Four way interleaving.

4   11 Reserved

2   Bits 7 through 4 must be set to 0 for the Truevision products.

1   Field 6:

2   Image Identification Field (variable):

3   Contains an identification field whose length in bytes is specified in field 1. If required, additionnal identification information may be stored after the image data field (field 8).

2   Field 7:

3   Color Map Data (variable): Field 4.3 specifies the width in bits of each color map entry while field 4.2 specifies the number of color-map entries in this field. Each color map is stored using an integral number bytes. The RGB specification for each color map entry is stored in successive bit-fields in the multi- byte entries are assumed to be (Field 4.3)/3 bits in length. Unused bit(s) in the multi-byte entries are assumed to specify attribute bits.

2   Field 8:

3   Image data field (variable): This field specifies (width x height) pixels. Each pixel specifies a color map index. The values for Width and Height are specified in fields 5.3 and 5.4 respectively. The attribute and color definition bits for each picxel are defined in fields 5.5 and 5.6, respectively. Each pixel is stored as an integral number of bytes and the color-map index is stored in the least significant bits of the field.

1   All fields are assumed to be unsigned. The low-order byte of two-byte field is stored first.

-------------------------------------------------------
|Data | Description |
|Type | |
|Field| |
|-------------------------------------------------------
| 0 | No Image Data Included |
|-------------------------------------------------------
| 1 | Uncompressed, Color Mapped (VDA/D and Targa M8)|
|-------------------------------------------------------
| 2 | Uncompressed, RGB Images |
|-------------------------------------------------------
| 3 | Uncompressed, Black and White Images |
|-------------------------------------------------------
| 9 | Run-Length Encoded Color Mapped Images |
|-------------------------------------------------------
| 10 | Run-Length Encoded RGB |
|-------------------------------------------------------
| 11 | Compressed, Black and White Images |
|-------------------------------------------------------
| 32 | Compressed Color-Mapped Data using Huffman, |
| | Delta, and Run_Length Encoding. |
|-------------------------------------------------------
| 33 | Compressed Color-Mapped Data using Huffman, |
| | Delta, and Run_Length Encoding. Data encoded |
| | for presentation in 4 passes. |
--------------------------------------------------------

Data type codes 0 to 127 (field 3) are reserved for use by Truevision Inc. for general applications. Data types 128 to 255 may be used for user-specific applications. Similarly, the first 128 map types codes (field 2) are reserved and the second set of 128 map type codes may be used for user-specific applications.

The information in this file was derived from Appendix C: TRUEVISION IMAGE FILE FORMATS of the TRUEVISION manual.

If the tag image type has not been implemented, a error message will be sent to the user.

Some other comments:

    An Option called EXTRASKIP LENGTH has been added due to problem encountered when converting tga images produced on a MACINTOSH.
    The -e flag is to get around a problem with some methods of transfering files from the Mac world to the Unix world. Most of these methods leave the Mac files alone, but a few of them add the "finderinfo" data onto the front of the Unix file. This means an extra 128 bytes to skip over when reading the file. The symptom to watch for is that the resulting PBM file looks shifted to one side. If you get this, try -e 128, and if that still doesn't look right try another value.

    This comment describes the pixel value storage in the case of an UNCOMPRESSED COLOR MAPPED RGB image. The Tga description is relatively unclear concerning the way the three bands are stored.
    In fact each pixel value is stored in successive bit-fields in the multi-byte entries. Each color bit field is assumed to be:

    Field bit length = ((field 5.5) - (bit 3-0 of field 5.6)) / 3bits

    Unused bit(s) in the multi-byte entries are assumed to specify attribute bits.

    In the case of TARGA 16, each pixel must be stored as two bytes. Each two-byte color value is composed of the following four fields:

    Bits 4-0 Blue Intensity.
    Bits 9-5 Green Intensity
    Bits 14-10 Red Intensity.
    Bit 15 Overlay Bit.

REQUIRED ARGUMENTS

-i  type: infile
    desc: input Truevision image file

-o  type: outfile
    desc: resulting output image (viff file)

OPTIONAL ARGUMENTS

-e  type: integer
    desc: Number of bytes to skip over when reading the file
    default: 0
    bounds: 0 < [-e] < 512

EXAMPLES
tga2viff -i image.tga -o image.xv

SEE ALSO
intro(1), verror(3), vgparms(3), vutils(3), ltga2viff(3) ltga2viff (3) lviff2tga (3) viff2tga (1)

RESTRICTIONS
tga2viff only works for Black$white images without color map or for RGB if the pixel depth is 24 or 32 bits and if the 3 bands R,G and B are 8 bits.

COPYRIGHT
Copyright 1991, University of New Mexico. All rights reserved.