simage  1.8.3
Coin3D texture image library
Loading...
Searching...
No Matches
simage.c File Reference
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <config.h>
#include <simage.h>
#include <simage_private.h>
#include <string.h>
#include <simage_jpeg.h>
#include <simage_png.h>
#include <simage_tga.h>
#include <simage_tiff.h>
#include <simage_pic.h>
#include <simage_rgb.h>
#include <simage_gif.h>

Data Structures

struct  _loader_data
 

Macros

#define SIMAGE_ERROR_BUFSIZE   512
 

Typedefs

typedef struct _loader_data loader_data
 

Functions

static void add_internal_loaders (void)
 
static void * add_loader (loader_data *loader, unsigned char *(*load_func)(const char *, int *, int *, int *), int(*identify_func)(const char *, const unsigned char *, int headerlen), int(*error_func)(char *, int), int is_internal, int addbefore)
 
static int cnt_bits (int val, int *highbit)
 
static loader_datafind_loader (const char *filename)
 
s_images_image_open (const char *filename, int oktoreadall)
 
int s_image_read_line (s_image *image, int line, unsigned char *buf)
 
void s_set_dynamic_loader_interface (s_dlopen_func *dlopen_func, s_dlsym_func *dlsym_func, s_dlclose_func *dlclose_func)
 
void * simage_add_loader (const struct simage_plugin *plugin, int addbefore)
 
int simage_check_supported (const char *filename)
 
void simage_clear_error (void)
 
void simage_free_image (unsigned char *imagedata)
 
const char * simage_get_last_error (void)
 
int simage_next_power_of_two (int val)
 
unsigned char * simage_read_image (const char *filename, int *width, int *height, int *numComponents)
 
void simage_remove_loader (void *handle)
 
void simage_version (int *major, int *minor, int *micro)
 

Variables

static s_dlclose_funcdlclose = NULL
 
static s_dlopen_funcdlopen = NULL
 
static s_dlsym_funcdlsym = NULL
 
static loader_datafirst_loader = NULL
 
static loader_data gif_loader
 
static loader_data jpeg_loader
 
static loader_datalast_loader = NULL
 
static loader_data pic_loader
 
static loader_data png_loader
 
static loader_data rgb_loader
 
char simage_error_msg [512+1]
 
static loader_data targa_loader
 
static loader_data tiff_loader
 

Macro Definition Documentation

◆ SIMAGE_ERROR_BUFSIZE

#define SIMAGE_ERROR_BUFSIZE   512

Typedef Documentation

◆ loader_data

typedef struct _loader_data loader_data

Function Documentation

◆ add_internal_loaders()

static void add_internal_loaders ( void )
static

◆ add_loader()

static void * add_loader ( loader_data * loader,
unsigned char *(*)(const char *, int *, int *, int *) load_func,
int(*)(const char *, const unsigned char *, int headerlen) identify_func,
int(*)(char *, int) error_func,
int is_internal,
int addbefore )
static

◆ cnt_bits()

static int cnt_bits ( int val,
int * highbit )
static

◆ find_loader()

static loader_data * find_loader ( const char * filename)
static

◆ s_image_open()

s_image * s_image_open ( const char * filename,
int oktoreadall )

◆ s_image_read_line()

int s_image_read_line ( s_image * image,
int line,
unsigned char * buf )

◆ s_set_dynamic_loader_interface()

void s_set_dynamic_loader_interface ( s_dlopen_func * dlopen_func,
s_dlsym_func * dlsym_func,
s_dlclose_func * dlclose_func )

◆ simage_add_loader()

void * simage_add_loader ( const struct simage_plugin * plugin,
int addbefore )

◆ simage_check_supported()

int simage_check_supported ( const char * filename)

Checks if image file format is supported. Returns 1 if filename can be loaded, 0 otherwise.

◆ simage_clear_error()

void simage_clear_error ( void )

◆ simage_free_image()

void simage_free_image ( unsigned char * imagedata)

Free resources allocated by either simage_read_image() or simage_resize() (Windows goes berzerk if you call free() from the client application)

◆ simage_get_last_error()

const char * simage_get_last_error ( void )

Returns error message, which is set when simage_read_image returned NULL or simage_write_image returns 0.

◆ simage_next_power_of_two()

int simage_next_power_of_two ( int val)

Returns the first 2^n bigger or equal to val. If simage_next_power_of_two(size) != size, you'll typically need to resize your image to be able to use it in an OpenGL app.

◆ simage_read_image()

unsigned char * simage_read_image ( const char * filename,
int * width,
int * height,
int * numcomponents )

Attempts to read filename, and return a pointer to the image data. NULL is returned if the image could not be loaded. The memory is allocated using malloc(), and it is the callers responsibility to free the memory (using free()) width and height contains the width and height of the image, and numcomponents is a number indicating the following:

1 : Grayscale image (GL_LUMINANCE) 2 : Grayscale with alpha channel (GL_LUMINANCE_ALPHA) 3 : RGB data (GL_RGB) 4 : RGB data with alpha component (GL_RGBA)

Returned image buffer must be freed by simage_free_image()

◆ simage_remove_loader()

void simage_remove_loader ( void * handle)

◆ simage_version()

void simage_version ( int * major,
int * minor,
int * micro )

Note specifically for Microsoft Windows that by leaving out the APIENTRY keyword for the function definitions, we default to the __cdecl calling convention. This is important to take into consideration when explicitly linking to the library at runtime: when using the wrong calling convention, obscure errors due to stack corruption can occur under certain (possibly rare) conditions.

Returns runtime version for simage.

Variable Documentation

◆ dlclose

s_dlclose_func* dlclose = NULL
static

◆ dlopen

s_dlopen_func* dlopen = NULL
static

◆ dlsym

s_dlsym_func* dlsym = NULL
static

◆ first_loader

loader_data* first_loader = NULL
static

◆ gif_loader

loader_data gif_loader
static

◆ jpeg_loader

loader_data jpeg_loader
static

◆ last_loader

loader_data* last_loader = NULL
static

◆ pic_loader

loader_data pic_loader
static

◆ png_loader

loader_data png_loader
static

◆ rgb_loader

loader_data rgb_loader
static

◆ simage_error_msg

char simage_error_msg[512+1]

◆ targa_loader

loader_data targa_loader
static

◆ tiff_loader

loader_data tiff_loader
static