Jo Engine  2023.08.26
Jo Sega Saturn Engine
Typedefs | Enumerations | Functions
tga.h File Reference

Jo Engine Truevision Targa format support. More...

Go to the source code of this file.

Typedefs

typedef jo_palette *(* jo_tga_palette_handling_callback) (void)
 Function prototype for () More...
 

Enumerations

enum  t_tga_error_code { JO_TGA_OK, JO_TGA_FILE_NOT_FOUND, JO_TGA_UNSUPPORTED_FORMAT, JO_TGA_OUT_OF_MEMORY }
 tga error code More...
 

Functions

void jo_set_tga_palette_handling (jo_tga_palette_handling_callback callback)
 Set the callback to handle TGA palette for 8 bits image. More...
 
t_tga_error_code jo_tga_loader_from_stream (jo_img *img, char *stream, const jo_color transparent_color)
 Load a TGA image from stream. More...
 
int jo_sprite_add_tga_from_stream (char *stream, const jo_color transparent_color)
 Add a sprite from a TGA stream. More...
 
int jo_sprite_add_tga (const char *const sub_dir, const char *const filename, const jo_color transparent_color)
 Add a sprite from a TGA file. More...
 
t_tga_error_code jo_tga_loader (jo_img *img, const char *const sub_dir, const char *const filename, const jo_color transparent_color)
 Load a TGA image. More...
 
t_tga_error_code jo_tga_8bits_loader (jo_img_8bits *img, const char *const sub_dir, const char *const filename, const int transparent_color_index_in_palette)
 Load a 8 bits 255 colors max TGA image. More...
 
t_tga_error_code jo_tga_8bits_loader_from_stream (jo_img_8bits *img, char *stream, const int transparent_color_index_in_palette)
 Load a 8 bits 255 colors max TGA image. More...
 
t_tga_error_code jo_tga_8bits_tileset_loader (const char *const sub_dir, const char *const filename, const jo_color transparent_color, const jo_tile *const tileset, const unsigned int tile_count, jo_raw_img *output_tiles)
 Load a tileset TGA image. More...
 
int jo_sprite_add_tga_tileset (const char *const sub_dir, const char *const filename, const jo_color transparent_color, const jo_tile *const tileset, const unsigned int tile_count)
 Add tileset sprites from a TGA file. More...
 

Detailed Description

Jo Engine Truevision Targa format support.

Author
Johannes Fetz
Bug:
jo_tga_tileset_loader is not tested

Typedef Documentation

◆ jo_tga_palette_handling_callback

typedef jo_palette*(* jo_tga_palette_handling_callback) (void)

Function prototype for ()

Enumeration Type Documentation

◆ t_tga_error_code

tga error code

Enumerator
JO_TGA_OK 
JO_TGA_FILE_NOT_FOUND 
JO_TGA_UNSUPPORTED_FORMAT 
JO_TGA_OUT_OF_MEMORY 

Function Documentation

◆ jo_set_tga_palette_handling()

void jo_set_tga_palette_handling ( jo_tga_palette_handling_callback  callback)

Set the callback to handle TGA palette for 8 bits image.

Parameters
callbackThe callback
Warning
This function is mandatory if you use 8 bits TGA

◆ jo_sprite_add_tga()

int jo_sprite_add_tga ( const char *const  sub_dir,
const char *const  filename,
const jo_color  transparent_color 
)

Add a sprite from a TGA file.

Parameters
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "A.TGA")
transparent_colorTransparent color or palette index for 8 bits image. Use JO_COLOR_Transparent by default
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
Sprite Id or -1 if failed

◆ jo_sprite_add_tga_from_stream()

int jo_sprite_add_tga_from_stream ( char *  stream,
const jo_color  transparent_color 
)

Add a sprite from a TGA stream.

Parameters
streamRaw TGA contents
transparent_colorTransparent color (see colors.h). Use JO_COLOR_Transparent by default
Returns
Sprite Id or -1 if failed

◆ jo_sprite_add_tga_tileset()

int jo_sprite_add_tga_tileset ( const char *const  sub_dir,
const char *const  filename,
const jo_color  transparent_color,
const jo_tile *const  tileset,
const unsigned int  tile_count 
)

Add tileset sprites from a TGA file.

Parameters
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "A.TGA")
transparent_colorTransparent color or palette index for 8 bits image. Use JO_COLOR_Transparent by default
tilesetTileset definition
tile_countNumber of tile in the entire image
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
Sprite Id of the first image or -1 if failed

◆ jo_tga_8bits_loader()

t_tga_error_code jo_tga_8bits_loader ( jo_img_8bits img,
const char *const  sub_dir,
const char *const  filename,
const int  transparent_color_index_in_palette 
)

Load a 8 bits 255 colors max TGA image.

Parameters
imgImage (set data to NULL for dynamic allocation)
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "A.TGA")
transparent_color_index_in_paletteTransparent color in palette index. Use 0 by default
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
t_tga_error_code

◆ jo_tga_8bits_loader_from_stream()

t_tga_error_code jo_tga_8bits_loader_from_stream ( jo_img_8bits img,
char *  stream,
const int  transparent_color_index_in_palette 
)

Load a 8 bits 255 colors max TGA image.

Parameters
imgImage (set data to NULL for dynamic allocation)
streamRaw TGA contents
transparent_color_index_in_paletteTransparent color in palette index. Use 0 by default
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
t_tga_error_code

◆ jo_tga_8bits_tileset_loader()

t_tga_error_code jo_tga_8bits_tileset_loader ( const char *const  sub_dir,
const char *const  filename,
const jo_color  transparent_color,
const jo_tile *const  tileset,
const unsigned int  tile_count,
jo_raw_img output_tiles 
)

Load a tileset TGA image.

Parameters
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "A.TGA")
transparent_colorTransparent color or palette index for 8 bits image. Use JO_COLOR_Transparent by default
tilesetTileset definition
tile_countNumber of tile in the entire image
output_tilesan array of tile_count * jo_raw_img.
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
t_tga_error_code

◆ jo_tga_loader()

t_tga_error_code jo_tga_loader ( jo_img img,
const char *const  sub_dir,
const char *const  filename,
const jo_color  transparent_color 
)

Load a TGA image.

Parameters
imgImage (set data to NULL for dynamic allocation)
sub_dirSub directory name (use JO_ROOT_DIR if the file is on the root directory)
filenameFilename (upper case and shorter as possible like "A.TGA")
transparent_colorTransparent color or palette index for 8 bits image. Use JO_COLOR_Transparent by default
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
t_tga_error_code

◆ jo_tga_loader_from_stream()

t_tga_error_code jo_tga_loader_from_stream ( jo_img img,
char *  stream,
const jo_color  transparent_color 
)

Load a TGA image from stream.

Parameters
imgImage (set data to NULL for dynamic allocation)
streamRaw TGA contents
transparent_colorTransparent color or palette index for 8 bits image. Use JO_COLOR_Transparent by default
Warning
The first index of the palette is 1 not 0. 0 (or JO_COLOR_Transparent) means no transparency.
The palette of 8 bits TGA must be 255 colors max not 256
Returns
t_tga_error_code