Defines | Functions | Variables

src/contrib/libtarga.c File Reference

#include <stdio.h>
#include <malloc.h>
#include "contrib/libtarga.h"
Include dependency graph for libtarga.c:

Go to the source code of this file.

Defines

#define TGA_IMG_NODATA   (0)
#define TGA_IMG_UNC_PALETTED   (1)
#define TGA_IMG_UNC_TRUECOLOR   (2)
#define TGA_IMG_UNC_GRAYSCALE   (3)
#define TGA_IMG_RLE_PALETTED   (9)
#define TGA_IMG_RLE_TRUECOLOR   (10)
#define TGA_IMG_RLE_GRAYSCALE   (11)
#define TGA_LOWER_LEFT   (0)
#define TGA_LOWER_RIGHT   (1)
#define TGA_UPPER_LEFT   (2)
#define TGA_UPPER_RIGHT   (3)
#define HDR_LENGTH   (18)
#define HDR_IDLEN   (0)
#define HDR_CMAP_TYPE   (1)
#define HDR_IMAGE_TYPE   (2)
#define HDR_CMAP_FIRST   (3)
#define HDR_CMAP_LENGTH   (5)
#define HDR_CMAP_ENTRY_SIZE   (7)
#define HDR_IMG_SPEC_XORIGIN   (8)
#define HDR_IMG_SPEC_YORIGIN   (10)
#define HDR_IMG_SPEC_WIDTH   (12)
#define HDR_IMG_SPEC_HEIGHT   (14)
#define HDR_IMG_SPEC_PIX_DEPTH   (16)
#define HDR_IMG_SPEC_IMG_DESC   (17)
#define TGA_ERR_NONE   (0)
#define TGA_ERR_BAD_HEADER   (1)
#define TGA_ERR_OPEN_FAILS   (2)
#define TGA_ERR_BAD_FORMAT   (3)
#define TGA_ERR_UNEXPECTED_EOF   (4)
#define TGA_ERR_NODATA_IMAGE   (5)
#define TGA_ERR_COLORMAP_FOR_GRAY   (6)
#define TGA_ERR_BAD_COLORMAP_ENTRY_SIZE   (7)
#define TGA_ERR_BAD_COLORMAP   (8)
#define TGA_ERR_READ_FAILS   (9)
#define TGA_ERR_BAD_IMAGE_TYPE   (10)
#define TGA_ERR_BAD_DIMENSIONS   (11)

Functions

static int16 ttohs (int16 val)
static int16 htots (int16 val)
static int32 ttohl (int32 val)
static int32 htotl (int32 val)
static uint32 tga_get_pixel (FILE *tga, ubyte bytes_per_pix, ubyte *colormap, ubyte cmap_bytes_entry)
static uint32 tga_convert_color (uint32 pixel, uint32 bpp_in, ubyte alphabits, uint32 format_out)
static void tga_write_pixel_to_mem (ubyte *dat, ubyte img_spec, uint32 number, uint32 w, uint32 h, uint32 pixel, uint32 format)
int tga_get_last_error ()
const char * tga_error_string (int error_code)
void * tga_create (int width, int height, unsigned int format)
void * tga_load (const char *filename, int *width, int *height, unsigned int format)
int tga_write_raw (const char *file, int width, int height, unsigned char *dat, unsigned int format)
int tga_write_rle (const char *file, int width, int height, unsigned char *dat, unsigned int format)

Variables

static uint32 TargaError

Define Documentation

#define HDR_CMAP_ENTRY_SIZE   (7)

Definition at line 78 of file libtarga.c.

#define HDR_CMAP_FIRST   (3)

Definition at line 76 of file libtarga.c.

#define HDR_CMAP_LENGTH   (5)

Definition at line 77 of file libtarga.c.

#define HDR_CMAP_TYPE   (1)

Definition at line 74 of file libtarga.c.

#define HDR_IDLEN   (0)

Definition at line 73 of file libtarga.c.

#define HDR_IMAGE_TYPE   (2)

Definition at line 75 of file libtarga.c.

#define HDR_IMG_SPEC_HEIGHT   (14)

Definition at line 82 of file libtarga.c.

#define HDR_IMG_SPEC_IMG_DESC   (17)

Definition at line 84 of file libtarga.c.

#define HDR_IMG_SPEC_PIX_DEPTH   (16)

Definition at line 83 of file libtarga.c.

#define HDR_IMG_SPEC_WIDTH   (12)

Definition at line 81 of file libtarga.c.

#define HDR_IMG_SPEC_XORIGIN   (8)

Definition at line 79 of file libtarga.c.

#define HDR_IMG_SPEC_YORIGIN   (10)

Definition at line 80 of file libtarga.c.

#define HDR_LENGTH   (18)

Definition at line 72 of file libtarga.c.

#define TGA_ERR_BAD_COLORMAP   (8)

Definition at line 96 of file libtarga.c.

#define TGA_ERR_BAD_COLORMAP_ENTRY_SIZE   (7)

Definition at line 95 of file libtarga.c.

#define TGA_ERR_BAD_DIMENSIONS   (11)

Definition at line 99 of file libtarga.c.

#define TGA_ERR_BAD_FORMAT   (3)

Definition at line 91 of file libtarga.c.

#define TGA_ERR_BAD_HEADER   (1)

Definition at line 89 of file libtarga.c.

#define TGA_ERR_BAD_IMAGE_TYPE   (10)

Definition at line 98 of file libtarga.c.

#define TGA_ERR_COLORMAP_FOR_GRAY   (6)

Definition at line 94 of file libtarga.c.

#define TGA_ERR_NODATA_IMAGE   (5)

Definition at line 93 of file libtarga.c.

#define TGA_ERR_NONE   (0)

Definition at line 88 of file libtarga.c.

#define TGA_ERR_OPEN_FAILS   (2)

Definition at line 90 of file libtarga.c.

#define TGA_ERR_READ_FAILS   (9)

Definition at line 97 of file libtarga.c.

#define TGA_ERR_UNEXPECTED_EOF   (4)

Definition at line 92 of file libtarga.c.

#define TGA_IMG_NODATA   (0)

Copyright (c) 2005 Michael L. Gleicher

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 57 of file libtarga.c.

#define TGA_IMG_RLE_GRAYSCALE   (11)

Definition at line 63 of file libtarga.c.

#define TGA_IMG_RLE_PALETTED   (9)

Definition at line 61 of file libtarga.c.

#define TGA_IMG_RLE_TRUECOLOR   (10)

Definition at line 62 of file libtarga.c.

#define TGA_IMG_UNC_GRAYSCALE   (3)

Definition at line 60 of file libtarga.c.

#define TGA_IMG_UNC_PALETTED   (1)

Definition at line 58 of file libtarga.c.

#define TGA_IMG_UNC_TRUECOLOR   (2)

Definition at line 59 of file libtarga.c.

#define TGA_LOWER_LEFT   (0)

Definition at line 66 of file libtarga.c.

#define TGA_LOWER_RIGHT   (1)

Definition at line 67 of file libtarga.c.

#define TGA_UPPER_LEFT   (2)

Definition at line 68 of file libtarga.c.

#define TGA_UPPER_RIGHT   (3)

Definition at line 69 of file libtarga.c.


Function Documentation

static int32 htotl ( int32  val  )  [static]

Definition at line 1250 of file libtarga.c.

static int16 htots ( int16  val  )  [static]

Definition at line 1225 of file libtarga.c.

static uint32 tga_convert_color ( uint32  pixel,
uint32  bpp_in,
ubyte  alphabits,
uint32  format_out 
) [static]

Definition at line 1131 of file libtarga.c.

void* tga_create ( int  width,
int  height,
unsigned int  format 
)

Definition at line 180 of file libtarga.c.

const char* tga_error_string ( int  error_code  ) 

Definition at line 127 of file libtarga.c.

int tga_get_last_error (  ) 

Definition at line 121 of file libtarga.c.

static uint32 tga_get_pixel ( FILE *  tga,
ubyte  bytes_per_pix,
ubyte *  colormap,
ubyte  cmap_bytes_entry 
) [static]

Definition at line 1079 of file libtarga.c.

void* tga_load ( const char *  filename,
int *  width,
int *  height,
unsigned int  format 
)

Definition at line 203 of file libtarga.c.

static void tga_write_pixel_to_mem ( ubyte *  dat,
ubyte  img_spec,
uint32  number,
uint32  w,
uint32  h,
uint32  pixel,
uint32  format 
) [static]

Definition at line 1033 of file libtarga.c.

int tga_write_raw ( const char *  file,
int  width,
int  height,
unsigned char *  dat,
unsigned int  format 
)

Definition at line 534 of file libtarga.c.

int tga_write_rle ( const char *  file,
int  width,
int  height,
unsigned char *  dat,
unsigned int  format 
)

Definition at line 672 of file libtarga.c.

static int32 ttohl ( int32  val  )  [static]

Definition at line 1236 of file libtarga.c.

static int16 ttohs ( int16  val  )  [static]

Definition at line 1214 of file libtarga.c.


Variable Documentation

uint32 TargaError [static]

Definition at line 103 of file libtarga.c.