Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
imagen::iTGA Class Reference

Reads / writes v1.0 and v2.0 Targa files. More...

#include <iTGA.h>

Inheritance diagram for imagen::iTGA:
imagen::iAbstractImage

List of all members.

Classes

struct  TargaDevField
 Targa Developer Field. More...
struct  TGA_DEVTAG
 Targa Developer Area Tag.
struct  TGA_EXTENSION
 Targa Extension Area.
struct  TGA_FOOTER
 Targa File Footer.
struct  TGA_HEADER
 Targa File Header.

Public Types

enum  TargaType {
  NoData = 0, ColMap = 1, TrueCol = 2, BW = 3,
  RLE_ColMap = 9, RLE_TrueCol = 10, RLE_BW = 11
}
enum  TargaOrigin { OriginBL = 0, OriginBR = 1, OriginUL = 2, OriginUR = 3 }
enum  TargaVersion { v1_0 = 1, v2_0 = 2 }

Public Member Functions

 iTGA ()
 Constructs a null image.
 iTGA (const iTGA &img)
 Copy constructor.
 iTGA (const iAbstractImage &img)
 iAbstractImage copy constructor.
 iTGA (int w, int h, iImageFormat f)
 Constructs an image with the given size and format.
 iTGA (Iubyte *d, int w, int h, iImageFormat f, int b)
 Constructs an image using an existing memory buffer.
 iTGA (const char *filename)
 Loads a Targa image file from disk.
 iTGA (Iubyte *buf, int len)
 Loads a Targa image from an existing memory buffer.
 iTGA (iDataStream *s)
 Loads a Targa image using an existing data stream.
 ~iTGA ()
 Destructor.
void clear ()
 Detaches this image from the image data and resets all data members to their initial values.
bool isFormatSupported (iImageFormat fmt) const
 Checks whether or not a given image color format is supported by this image type.
void setImageID (const char id[255])
 Sets the TGA Image ID.
const char * getImageID () const
 Returns a pointer to the TGA Image ID.
void setTargaVersion (TargaVersion ver)
 Sets the image's TGA version.
TargaVersion getTargaVersion () const
 Gets the image's TGA version.
void addDevField (const TargaDevField &field)
 Appends a developer field to the Developer Field list.
void setJobName (const char *name)
 Set the name of the job to which this image is associated.
const char * getJobName () const
 Returns a pointer to the job name.
void enableRLE (bool brle)
 Enables RLE compression when writing a Targa image.
void enableExtension (bool bext)
 Enables the Extension Area when writing a v2.0 Targa image.
void enableDevArea (bool bdev)
 Enables the Developer Area when writing a v2.0 Targa image.
iTGAoperator= (const iTGA &img)
iTGAoperator= (const iAbstractImage &img)

Static Public Member Functions

static bool isValid (iDataStream *s)

Protected Member Functions

void init ()
bool loadImage ()
bool saveImage ()

Detailed Description

Reads / writes v1.0 and v2.0 Targa files.

Extensions:
.tga, .vda, .icb, and .vst

Image types:
Uncompressed and RLE compressed colormapped, truecolor, and grayscale
Types 1, 2, 3, 9, 10, and 11

Pixel Depths:
8-bit, 16-bit, 24-bit, and 32-bit

TODO:
Read/write 16-bit color palettes
Read/write 16-bit images.
Write: RLE compression.

Adding developer fields

For more detailed information on Developer Fields, consult the Truevision Targa File Format Specification (version 2.0)
After creating a TGA image, you can add developer fields to it. First create a TargaDevField:

    // 'd' is a pointer to the field data
    // 's' is the size of the field data
    // 'id' is the tag ID
    TargaDevField field(d, s, id);

Then, simply add it to the list of developer fields:

    // 'itga' is an iTGA object
    // 'field' is a TargaDevField object
    itga.addDevField(field);

Member Enumeration Documentation

Enumerator:
NoData 
ColMap 
TrueCol 
BW 
RLE_ColMap 
RLE_TrueCol 
RLE_BW 
Enumerator:
OriginBL 
OriginBR 
OriginUL 
OriginUR 
Enumerator:
v1_0 
v2_0 

Constructor & Destructor Documentation

Constructs a null image.

imagen::iTGA::iTGA ( const iTGA img)

Copy constructor.

This copies all image attributes, and attaches itself to img's shared data.

iAbstractImage copy constructor.

imagen::iTGA::iTGA ( int  w,
int  h,
iImageFormat  f 
)

Constructs an image with the given size and format.

The image data will be allocated, but not initialized.

Parameters:
w: Image width.
h: Image height.
f: Image format.
imagen::iTGA::iTGA ( Iubyte d,
int  w,
int  h,
iImageFormat  f,
int  b 
)

Constructs an image using an existing memory buffer.

The memory buffer will not be deleted at destruction.

See also:
loadData()
imagen::iTGA::iTGA ( const char *  filename)

Loads a Targa image file from disk.

See also:
load( const char *filename )
imagen::iTGA::iTGA ( Iubyte buf,
int  len 
)

Loads a Targa image from an existing memory buffer.

See also:
load( Iubyte *buf, int len )

Loads a Targa image using an existing data stream.

See also:
load( iDataStream *s )

Destructor.


Member Function Documentation

void imagen::iTGA::clear ( ) [virtual]

Detaches this image from the image data and resets all data members to their initial values.

Reimplemented from imagen::iAbstractImage.

bool imagen::iTGA::isFormatSupported ( iImageFormat  fmt) const [virtual]

Checks whether or not a given image color format is supported by this image type.

Returns:
True if the format is supported, else false.

Implements imagen::iAbstractImage.

static bool imagen::iTGA::isValid ( iDataStream s) [static]
void imagen::iTGA::setImageID ( const char  id[255])

Sets the TGA Image ID.

const char* imagen::iTGA::getImageID ( ) const [inline]

Returns a pointer to the TGA Image ID.

Sets the image's TGA version.

This will determine whether a v1.0 or v2.0 Targa image file is written.
The version is set to v2_0 by default.

Gets the image's TGA version.

void imagen::iTGA::addDevField ( const TargaDevField field) [inline]

Appends a developer field to the Developer Field list.

The Developer Field list can contain up to 65535 fields.
They will be embedded in the image file if the Developer Area is enabled.

void imagen::iTGA::setJobName ( const char *  name) [inline]

Set the name of the job to which this image is associated.

This function will probably be moved to iAbstractImage in the future.

const char* imagen::iTGA::getJobName ( ) const [inline]

Returns a pointer to the job name.

This function will probably be moved to iAbstractImage in the future.

void imagen::iTGA::enableRLE ( bool  brle) [inline]

Enables RLE compression when writing a Targa image.

It is NOT enabled by default, but probably will be in the near future.

void imagen::iTGA::enableExtension ( bool  bext) [inline]

Enables the Extension Area when writing a v2.0 Targa image.

It is disabled by default.

void imagen::iTGA::enableDevArea ( bool  bdev) [inline]

Enables the Developer Area when writing a v2.0 Targa image.

It is disabled by default.

iTGA& imagen::iTGA::operator= ( const iTGA img)
iTGA& imagen::iTGA::operator= ( const iAbstractImage img)

Reimplemented from imagen::iAbstractImage.

void imagen::iTGA::init ( ) [protected]

Reimplemented from imagen::iAbstractImage.

bool imagen::iTGA::loadImage ( ) [protected, virtual]
bool imagen::iTGA::saveImage ( ) [protected, virtual]

The documentation for this class was generated from the following file: