TGA/PPM File Converter and Texture Generator

This is a TGA (Targa)/PPM (Portable PixMap) file format conversion and procedural texture generation program. The program will read in either Old TGA or v2.0 New TGA that are either 24 or 32 bit true color images or 8 bit color mapped images. Color maps which have color map entries that are 15, 16, 24 and 32 bits wide are supported. Compressed TGA format is not supported at this time. The program will also read in either ASCII PPM or binary PPM files. The program allows quantization of 24 bit images or 8 bit color mapped images to TGA color mapped images that have between 2 and 256 colors. Floyd-Steinberg dithering can also be done. The procedural texture generation method is Nth closest point.

The command line options are:

-quantize < 2..256 >: Quantizes the input image to the number of colors specified. Uses Heckbert's Median Cut algorithm to quantize.

-dither < Floyd >: Dithers the image using Floyd-Steinberg dithering. Note that this takes a while to do.

-oformat < format >: Specifies the desired output format. If this option is absent, the output format is assumed to be that of the input format. < format > may be one of the following strings:

ppm The PPM file format - only 24-bit files (cannot be used with the quantize option, as PPM does not support color maps)

tga The TGA file format - 24/32 bit and 8 bit color mapped uncompressed files

-depth < depth >: This option indicates the desired depth of the output image. The only supported values for < depth > are 24 and 32. If the input image is a 32-bit file that is pre-multiplied, the alpha data will be unmultiplied before it is written out to the output file. This option cannot be used with the quantize option (as quantize assumes 8 bit or less output)

-in < filename >: Specifies the file to be processed.

-out < filename >: Specifies the file to be written to.

-textureimage rwidth rheight: This option specifies that the image specified by the -in parameter is to be made tileable. rwidth and rheight specifiy how many pixels deep the reflected zone at the left/right and top/bottom shall be, respectively. rwidth and rheight must be less than half the input image's width and height respectively.

-texturesize owidth oheight: This specifies the size of the frame buffer you are to use if you are NOT starting from an input image. If there is no -in option, this option must be specified in order to use any of the -texturecolor, -texturenearest pairs. If the -in option IS specified, then the frame buffer width and height is taken from the specified image and a warning is produced. This option cannot be specified more than once.

-texturecolor r g b a: The option specifies an RGBA color for successive calls to texturenearest. If texturecolor is not specified at all, a gray scale output (8 bits) with full alpha is assumed. This color is modulated by each computed intensity to arrive at the value to be composited (via the OVER operator) into the frame buffer. In this way, several textures can be layed over each other in differing colors and opacities. The allowable values for r,g,b,a are numbers from 0 to 255.

-texturenearest expression: This option specifies that a texture be created using the Nth nearest neighbor method. expression is a string enclosed in double quotes which can have +, -, /, *, (, ), sin, cos operators. An example expression is: "(sin(f3-f1)+1)/2". fn specifies that the intensity should be computed based on the distance between the current pixel and the nth closest seed point. Remember to always include both opening and closing parentheses.

An example command line:

texture -in picture -textureimage 50 50 -texturecolor 200 100 50 127 -texturenearest "(f1+2*f3)/3" -texturecolor 50 200 100 64 -texturenearest "(f3+f4)/2" -oformat tga -depth 32 -out foo

This command line would initialize the frame buffer to "picture" and then make it tileable by folding over 50 pixels from each side. Then a reddish texture is layered over the top with 50 percent opacity (127/255 == 50%). Then a greenish texture is layered over the top with 25 percent opacity. The results are translated into the file foo in the TGA file format.

If you would like to have more information,


This page last modified 4/18/99