POV-Ray : Newsgroups : povray.general : hacking TARGA the easy way : Re: hacking TARGA the easy way Server Time
9 Aug 2024 03:20:37 EDT (-0400)
  Re: hacking TARGA the easy way  
From: Christoph Hormann
Date: 29 Aug 2000 08:46:51
Message: <39ABB0EA.FDB7ECB4@schunter.etc.tu-bs.de>
Warp wrote:
> 
>   The raw targa file format outputted by povray is extremely simple. It has
> 18 bytes of header data at the beginning and then the image follows as raw
> data. I don't remember which pair of 16 bits of the header data tells the
> dimensions of the image but that should be easy to discover (either by
> lookin it up in some spec or by examining the header directly with a
> hex editor (and knowing the dimensions of the image)).
> 

As i already posted in p.b.i some time ago, the tga header has the following
form (pascal/delphi syntax):

   T_TGA_header = packed record
    ID_size: Byte;            { ID-Field                   }
    Palette: Byte;            { 1= Palette exists          }
    Typ: Byte;                { Type (Mono, Color, compr.) }
    Pal_index: Word;         
    Pal_size: Word;          
    Pal_entry_size: Byte;    
    Lx    : Word;            
    Ly    : Word;            
    cX    : Word;             { Width                      }
    cY    : Word;             { Height                     }
    Bppix : Byte;             { Bits per Pixel - 1, 8, 24  }
    Image_des: Byte;          { Image Descriptor Flag      }
   end;

If Palette is 1 this if followed by a 3x256 byte palette of rgb triples. 
Otherwise only the raw data array is appended (RLE compression in some cases,
but that should not be neccessary here).

Christoph

--
Christoph Hormann <chr### [at] gmxde>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.