D:/Projects/dark-oberon.svn/game/sources/libtga/tga.cpp File Reference


Detailed Description

Author:
Marcus Geelnard, Peter Knut
Date:
2002 - 2006
TGA Loader Library

Supports the Truevision Targa version 1 fileformat (.TGA). Supported pixel formats are:

Paletted images are translated into true color or truecolor+alpha pixel formats.

Version:
1.0 - Initial.

#include <stdlib.h>
#include <stdio.h>
#include "tga.h"

Classes

struct  TGA_Header

Defines

#define TGA_CMAPTYPE_NONE   0
 Value of TGA_Header::cmaptype, when there is no colormap present.
#define TGA_CMAPTYPE_PRESENT   1
 Value of TGA_Header::cmaptype, when there is a colormap present.
#define TGA_IMAGETYPE_NONE   0
 Value of TGA_Header::imagetype.
#define TGA_IMAGETYPE_CMAP   1
 Value of TGA_Header::imagetype.
#define TGA_IMAGETYPE_TC   2
 Value of TGA_Header::imagetype.
#define TGA_IMAGETYPE_GRAY   3
 Value of TGA_Header::imagetype.
#define TGA_IMAGETYPE_CMAP_RLE   9
 Value of TGA_Header::imagetype.
#define TGA_IMAGETYPE_TC_RLE   10
 Value of TGA_Header::imagetype.
#define TGA_IMAGETYPE_GRAY_RLE   11
 Value of TGA_Header::imagetype.
#define TGA_IMAGEINFO_ALPHA_MASK   0x0f
 Mask to get TGA_Header::_alphabits from TGA_Header::imageinfo;.
#define TGA_IMAGEINFO_ALPHA_SHIFT   0
 Shift to get TGA_Header::_alphabits from TGA_Header::imageinfo;.
#define TGA_IMAGEINFO_ORIGIN_MASK   0x30
 Mask to get TGA_Header::_origin from TGA_Header::imageinfo;.
#define TGA_IMAGEINFO_ORIGIN_SHIFT   4
 Shift to get TGA_Header::_origin from TGA_Header::imageinfo;.
#define _TGA_ORIGIN_BL   0
 Bottom left image origin.
#define _TGA_ORIGIN_BR   1
 Bottom right image origin.
#define _TGA_ORIGIN_UL   2
 Upper left image origin.
#define _TGA_ORIGIN_UR   3
 Upper right image origin.

Functions

void tgaPrepare (TGA *tga)
int tgaReadHeader (void *source, TGA *tga, TGA_Header *h)
void tgaReadRLE (void *source, TGA *tga, unsigned char *buf, int size, int bpp)
long tgaRead (void *source, TGA *tga, int flags)
long tgaRead (const char *file_name, TGA *tga, int flags)
long tgaRead (FILE *fd, TGA *tga, int flags)
static int tgaWriteHeader (void *source, TGA *tga, TGA_Header *h)
int tgaWrite (void *source, TGA *tga, int flags)
int tgaWrite (const char *file_name, TGA *tga, int flags)
int tgaWrite (FILE *fd, TGA *tga, int flags)


Define Documentation

#define _TGA_ORIGIN_BL   0

Bottom left image origin.

#define _TGA_ORIGIN_BR   1

Bottom right image origin.

#define _TGA_ORIGIN_UL   2

Upper left image origin.

#define _TGA_ORIGIN_UR   3

Upper right image origin.

#define TGA_CMAPTYPE_NONE   0

Value of TGA_Header::cmaptype, when there is no colormap present.

#define TGA_CMAPTYPE_PRESENT   1

Value of TGA_Header::cmaptype, when there is a colormap present.

#define TGA_IMAGEINFO_ALPHA_MASK   0x0f

Mask to get TGA_Header::_alphabits from TGA_Header::imageinfo;.

#define TGA_IMAGEINFO_ALPHA_SHIFT   0

Shift to get TGA_Header::_alphabits from TGA_Header::imageinfo;.

#define TGA_IMAGEINFO_ORIGIN_MASK   0x30

Mask to get TGA_Header::_origin from TGA_Header::imageinfo;.

#define TGA_IMAGEINFO_ORIGIN_SHIFT   4

Shift to get TGA_Header::_origin from TGA_Header::imageinfo;.

#define TGA_IMAGETYPE_CMAP   1

Value of TGA_Header::imagetype.

#define TGA_IMAGETYPE_CMAP_RLE   9

Value of TGA_Header::imagetype.

#define TGA_IMAGETYPE_GRAY   3

Value of TGA_Header::imagetype.

#define TGA_IMAGETYPE_GRAY_RLE   11

Value of TGA_Header::imagetype.

#define TGA_IMAGETYPE_NONE   0

Value of TGA_Header::imagetype.

Todo:
okomentovat vsetky TGA_IMAGETYPE_*

#define TGA_IMAGETYPE_TC   2

Value of TGA_Header::imagetype.

#define TGA_IMAGETYPE_TC_RLE   10

Value of TGA_Header::imagetype.


Function Documentation

void tgaPrepare ( TGA tga  ) 

long tgaRead ( FILE *  fd,
TGA tga,
int  flags 
)

long tgaRead ( const char *  file_name,
TGA tga,
int  flags 
)

long tgaRead ( void *  source,
TGA tga,
int  flags 
)

Reads a TGA image from a file.

Parameters:
source Data source to read the TGA image from.
tga Pointer to information structure which will be filled by the function.
flags Flags TGA_ORIGIN_UL, ... .
Returns:
1 on success, 0 otherwise.

int tgaReadHeader ( void *  source,
TGA tga,
TGA_Header h 
)

Reads a TGA file header and checks that it is valid.

Returns:
1 when the TGA header was valid, 0 otherwise.

void tgaReadRLE ( void *  source,
TGA tga,
unsigned char *  buf,
int  size,
int  bpp 
)

Reads Run-Length Encoded data.

int tgaWrite ( FILE *  fd,
TGA tga,
int  flags 
)

int tgaWrite ( const char *  file_name,
TGA tga,
int  flags 
)

int tgaWrite ( void *  source,
TGA tga,
int  flags 
)

static int tgaWriteHeader ( void *  source,
TGA tga,
TGA_Header h 
) [static]


Generated on Sat Oct 20 14:47:30 2007 for Dark Oberon by  doxygen 1.5.3