POV-Ray : Newsgroups : povray.general : hacking TARGA the easy way Server Time
9 Aug 2024 09:07:32 EDT (-0400)
  hacking TARGA the easy way (Message 1 to 8 of 8)  
From: matt giwer
Subject: hacking TARGA the easy way
Date: 27 Aug 2000 23:23:49
Message: <39A9DB9E.40EF8D3@ij.net>
Create an image with any utility even POVray of the size you want and
save as .tga. 

	Look at with a hex editor. Duplicate everything up to the long string
of zero. 

-- 
Meaningless Adjectives Department
Proud warriors; vibrant culture; stupid liberal;
	-- The Iron Webmaster, 38


Post a reply to this message

From: Andrea Ryan
Subject: Re: hacking TARGA the easy way
Date: 28 Aug 2000 12:52:44
Message: <39AA95AF.7BEF9D13@global2000.net>
http://www.wotsit.org/
There are specifications of file formats there, even gif with LZW.  I won't do
anything with the gif one for two years until the patent expires or just use the
better png format now.
Brendan

matt giver wrote:

>         Create an image with any utility even POVray of the size you want and
> save as .tga.
>
>         Look at with a hex editor. Duplicate everything up to the long string
> of zero.
>
> --
> Meaningless Adjectives Department
> Proud warriors; vibrant culture; stupid liberal;
>         -- The Iron Webmaster, 38


Post a reply to this message

From: matt giwer
Subject: Re: hacking TARGA the easy way
Date: 28 Aug 2000 14:46:43
Message: <39AAB3F7.6E6E7ECA@ij.net>
Andrea Ryan wrote:
> 
> http://www.wotsit.org/
> There are specifications of file formats there, even gif with LZW.  I won't do
> anything with the gif one for two years until the patent expires or just use the
> better png format now.
> Brendan 

	Honestly, they don't make a lick of sense to me. Nor can I reconcile
them with what I see in a hex editor and that includes targa. I have
tried to do it from the specs for years. This was an inspiration of just
a few days ago. 

> matt giver wrote:
> 
> >         Create an image with any utility even POVray of the size you want and
> > save as .tga.
> >
> >         Look at with a hex editor. Duplicate everything up to the long string
> > of zero.
> >
> > --
> > Meaningless Adjectives Department
> > Proud warriors; vibrant culture; stupid liberal;
> >         -- The Iron Webmaster, 38

-- 
If I were told WWII had been conducted in secret,
that all but a few documents had been destroyed,
that those documents were all in code words, and
it took a court to establish that it happened, 
damned right I would be skeptical.
	-- The Iron Webmaster, 32


Post a reply to this message

From: Jon A  Cruz
Subject: Re: hacking TARGA the easy way
Date: 29 Aug 2000 01:05:40
Message: <39AB44E4.C1E17EF6@geocities.com>
matt giwer wrote:

> Andrea Ryan wrote:
> >
> > http://www.wotsit.org/
> > There are specifications of file formats there, even gif with LZW.  I won't do
> > anything with the gif one for two years until the patent expires or just use the
> > better png format now.
> > Brendan
>
>         Honestly, they don't make a lick of sense to me. Nor can I reconcile
> them with what I see in a hex editor and that includes targa. I have
> tried to do it from the specs for years. This was an inspiration of just
> a few days ago.

Not bad as far as targa goes. The first 18 bytes is what matters.
Get the postscript version of the targa specs and it's all very simple. Just ignore
the new 2.0 stuff at the end of the file and stick with the 18 byte header.

Oh. Perhaps you didn't have the official targa docs.
Go to The Graphics File Formats Page at
http://www.dcs.ed.ac.uk/home/mxr/gfx/2d-hi.html

Get the two postscript files listed there. Way back when (1991?), I got them mailed
to me free from Truevision, and this is the same thing. Just ignore the new 2.0 stuff
that's all at the end of the file.


Post a reply to this message

From: Warp
Subject: Re: hacking TARGA the easy way
Date: 29 Aug 2000 08:32:28
Message: <39abad5b@news.povray.org>
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)).

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Christoph Hormann
Subject: Re: hacking TARGA the easy way
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

From: Jon A  Cruz
Subject: Re: hacking TARGA the easy way
Date: 29 Aug 2000 12:27:26
Message: <39ABE4AE.D6B4D7D0@geocities.com>
Christoph Hormann wrote:

> 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).

Just a few minor clarifications from the specs:

In this usage, Word is 2 bytes and stored in little-endian (Intel) format.

ID-Field is the number of bytes in the image ID field. Could be up to 255,
although 0 (no id string) is most common.

The Image ID (if present) comes after the 18 byte header and before the color
map. If this value is not zero, the not skipping that many bytes will mess up
your read.

The values for type are:
    0 - no image data
    1 - uncompressed color mapped
    2 - uncompressed true color
    3 - uncompressed black & white
    9 - RLE color mapped
    10 - RLE true color
    11 - RLE black & white

Pal_entry_size is in bits per entry. often 15, 16, 24 or 32.

The palette is not always 3x256. It is # of entries times entry size in bytes.
Or
((Pal_entry_size + 7) >> 3) * Pal_size

Lx and Ly are the offset of the start position of the image. (i.e. the place to
start drawing the image if it's a sprite). Usually this can be ignored.

The Image Descriptor Flag is broken into three parts, one of which is unused.
bits 3-0 are the # of bits for the alpha channel.
bits 4-5 are the image orgin
bits 6-7 are unused.

If bit 4 is set, the image data starts on the right, if bit 4 is clear, the
image data starts on the left.
If bit 5 is set, the image data starts at the top, if bit 5 is clear, the image
data starts at the bottom.


Post a reply to this message

From: Matt Giwer
Subject: Re: hacking TARGA the easy way
Date: 29 Aug 2000 19:30:55
Message: <39AC4829.1693F3C@ij.net>
Christoph Hormann wrote:
> 
> 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.

	Triples in the order B G R. 

> Otherwise only the raw data array is appended (RLE compression in some cases,
> but that should not be neccessary here).

-- 
Pat Buchanan or the American Empire of Earth.
The choice is yours. 
	-- The Iron Webmaster, 43


Post a reply to this message

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