Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.opengl.util.texture.spi
Class TGAImage

    java.lang.Object
      com.sun.opengl.util.texture.spi.TGAImage

    public class TGAImage

extends Object

Targa image reader and writer adapted from sources of the Jimi image I/O class library.

Image decoder for image data stored in TGA file format. Currently only the original TGA file format is supported. This is because the new TGA format has data at the end of the file, getting to the end of a file in an InputStream orient environment presents several difficulties which are avoided at the moment.

This is a simple decoder and is only setup to load a single image from the input stream

Version:
  $Revision: 1.1 $
Author:
  Robin Luiten, Kenneth Russell

Nested Class Summary
`static class` | `TGAImage.Header` This class reads in all of the TGA image header in addition it also reads in the imageID field as it is convenient to handle that here.

Method Summary
`static TGAImage` | `createFromData(int width, int height, boolean hasAlpha, boolean topToBottom, ByteBuffer data)` Creates a TGAImage from data supplied by the end user.
`ByteBuffer` | `getData()` Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D.
`int` | `getGLFormat()` Returns the OpenGL format for this texture; e.g.
`int` | `getHeight()` Returns the height of the image.
`int` | `getWidth()` Returns the width of the image.
`static TGAImage` | `read(InputStream in)` Reads a Targa image from the specified InputStream.
`static TGAImage` | `read(String filename)` Reads a Targa image from the specified file.
`void` | `write(File file)` Writes the image in Targa format to the specified file.
`void` | `write(String filename)` Writes the image in Targa format to the specified file name.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getWidth

    public int getWidth()

  Returns the width of the image.

### getHeight

    public int getHeight()

  Returns the height of the image.

### getGLFormat

    public int getGLFormat()

  Returns the OpenGL format for this texture; e.g. GL.GL_BGR or GL.GL_BGRA.

### getData

    public ByteBuffer getData()

  Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D.

### read

    public static TGAImage read(String filename)
                         throws IOException

  Reads a Targa image from the specified file.

  Throws:
    `IOException`

### read

    public static TGAImage read(InputStream in)
                         throws IOException

  Reads a Targa image from the specified InputStream.

  Throws:
    `IOException`

### write

    public void write(String filename)
               throws IOException

  Writes the image in Targa format to the specified file name.

  Throws:
    `IOException`

### write

    public void write(File file)
               throws IOException

  Writes the image in Targa format to the specified file.

  Throws:
    `IOException`

### createFromData

    public static TGAImage createFromData(int width,
                                          int height,
                                          boolean hasAlpha,
                                          boolean topToBottom,
                                          ByteBuffer data)

  Creates a TGAImage from data supplied by the end user. Shares data with the passed ByteBuffer. Assumes the data is already in the correct byte order for writing to disk, i.e., BGR or BGRA.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.