Jo Engine  2024.04.28
Jo Sega Saturn Engine
tga.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2024, Johannes Fetz (johannesfetz@gmail.com)
4 ** All rights reserved.
5 **
6 ** Redistribution and use in source and binary forms, with or without
7 ** modification, are permitted provided that the following conditions are met:
8 ** * Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** * Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** * Neither the name of the Johannes Fetz nor the
14 ** names of its contributors may be used to endorse or promote products
15 ** derived from this software without specific prior written permission.
16 **
17 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 ** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
35 #ifndef __JO_TGA_H__
36 # define __JO_TGA_H__
37 
38 #ifdef JO_COMPILE_WITH_TGA_SUPPORT
39 
40 /*
41 ** TYPEDEFS
42 */
44 typedef jo_palette* (*jo_tga_palette_handling_callback)(void);
45 
47 typedef enum
48 {
49  JO_TGA_OK = 0,
54 
60 
67 
76 t_tga_error_code jo_tga_loader_from_stream(jo_img *img, char *stream, const jo_color transparent_color);
77 
83 int jo_sprite_add_tga_from_stream(char *stream, const jo_color transparent_color);
84 
85 #ifdef JO_COMPILE_WITH_FS_SUPPORT
86 
95 int jo_sprite_add_tga(const char * const sub_dir, const char * const filename, const jo_color transparent_color);
96 
106 t_tga_error_code jo_tga_loader(jo_img *img, const char * const sub_dir, const char *const filename, const jo_color transparent_color);
107 
117 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);
118 
127 t_tga_error_code jo_tga_8bits_loader_from_stream(jo_img_8bits *img, char *stream, const int transparent_color_index_in_palette);
128 
140 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);
141 
152 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);
153 
154 #endif /* !JO_COMPILE_WITH_FS_SUPPORT */
155 
156 #endif /* !JO_COMPILE_WITH_TGA_SUPPORT */
157 
158 #endif /* !__JO_TGA_H__ */
159 
160 /*
161 ** END OF FILE
162 */
jo_tga_palette_handling_callback
jo_palette *(* jo_tga_palette_handling_callback)(void)
Function prototype for ()
Definition: tga.h:44
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.
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.
JO_TGA_UNSUPPORTED_FORMAT
@ JO_TGA_UNSUPPORTED_FORMAT
Definition: tga.h:51
jo_palette
Palette contents struct.
Definition: types.h:250
jo_tile
Struct of one tile (pos and size)
Definition: types.h:257
jo_color
unsigned short jo_color
15 bits color type
Definition: types.h:42
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.
jo_img_8bits
8 bits image struct
Definition: types.h:234
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.
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.
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.
JO_TGA_OK
@ JO_TGA_OK
Definition: tga.h:49
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.
JO_TGA_FILE_NOT_FOUND
@ JO_TGA_FILE_NOT_FOUND
Definition: tga.h:50
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.
JO_TGA_OUT_OF_MEMORY
@ JO_TGA_OUT_OF_MEMORY
Definition: tga.h:52
t_tga_error_code
t_tga_error_code
tga error code
Definition: tga.h:48
jo_set_tga_default_palette
void jo_set_tga_default_palette(jo_palette *palette)
Set the palette to use for 8 bits image.
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.
jo_raw_img
Raw image struct.
Definition: types.h:242
jo_img
15 bits image struct
Definition: types.h:226