com.sun.j3d.loaders.lw3d
Class TargaReader

java.lang.Object
  extended by com.sun.j3d.loaders.lw3d.ParserObject
      extended by com.sun.j3d.loaders.lw3d.TargaReader

 class TargaReader
extends ParserObject

This class parses a standard Targa file and retrieves the image stored therein, storing the pixel data in a BufferedImage.


Field Summary
(package private)  java.io.BufferedInputStream bufferedReader
           
(package private)  java.awt.Image theImage
           
 
Fields inherited from class com.sun.j3d.loaders.lw3d.ParserObject
debugPrinter, EXCEPTION, LINE_TRACE, MISC, NONE, TIME, TRACE, VALUES, WARNING
 
Constructor Summary
TargaReader(java.lang.String fileName, int debugVals)
          Constructor: creates file reader and calls parseFile() to do the real work
 
Method Summary
(package private)  java.awt.Image getImage()
          Returns the image that was created from parsing the targa file (null if the file reading failed)
(package private)  void parseFile()
          This method parses the file and stores the pixel data in a BufferedImage.
 
Methods inherited from class com.sun.j3d.loaders.lw3d.ParserObject
debugOutput, debugOutputLn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bufferedReader

java.io.BufferedInputStream bufferedReader

theImage

java.awt.Image theImage
Constructor Detail

TargaReader

TargaReader(java.lang.String fileName,
            int debugVals)
      throws java.io.FileNotFoundException
Constructor: creates file reader and calls parseFile() to do the real work

Throws:
java.io.FileNotFoundException
Method Detail

getImage

java.awt.Image getImage()
Returns the image that was created from parsing the targa file (null if the file reading failed)


parseFile

void parseFile()
         throws IncorrectFormatException,
                ParsingErrorException
This method parses the file and stores the pixel data in a BufferedImage. The basic file format is: Byte Description 0 Image ID Length 1 Colormap type 2 Image Type 3-4 Colormap spec: 1st entry index 5-6 Colormap spec: length 7 Colormap spec: entry size 8-9 X-origin of lower-left corner 10-11 Y-origin of lower-left corner 12-13 Image width 14-15 Image height 16 Pixel depth 17 00(origin)(alpha) first 2 bytes 0, next 2 starting corner, last four number of overlay bits per pixel 18- Image ID ?? Colormap data ?? Image Data ?? Developer Area ?? Extension Area ?? File Footer We're going to make some assumptions about the format of files we're asked to load. In particular, we're not going to do any colormpa-based images: the images need to be either 24-bit or 32-bit true color. We're also going to ignore vaiours parameters in the header block, since they complicate life and don't appear to be used in Lightwave image files. In particular, the following fields will be ignored: Image ID, colormap info, xy origins, and alpha/overlay bits.

Throws:
IncorrectFormatException
ParsingErrorException


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.