Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
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_gdiplus.h>
#include <simage_tga.h>
#include <simage_pic.h>
#include <simage_rgb.h>

Data Structures

struct  _loader_data




typedef struct _loader_data loader_data


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 loader_datafind_loader (const char *filename)
static void add_internal_loaders (void)
unsigned char * simage_read_image (const char *filename, int *width, int *height, int *numComponents)
const char * simage_get_last_error (void)
void simage_clear_error (void)
int simage_check_supported (const char *filename)
void * simage_add_loader (const struct simage_plugin *plugin, int addbefore)
void simage_remove_loader (void *handle)
static int cnt_bits (int val, int *highbit)
int simage_next_power_of_two (int val)
void simage_version (int *major, int *minor, int *micro)
void simage_free_image (unsigned char *imagedata)
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, s_dlsym_func *dlsym, s_dlclose_func *dlclose)


static loader_data gdiplus_loader
static loader_data targa_loader
static loader_data pic_loader
static loader_data rgb_loader
static loader_datafirst_loader = NULL
static loader_datalast_loader = NULL
char simage_error_msg [512+1]
static s_dlopen_funcdlopen = NULL
static s_dlsym_funcdlsym = NULL
static s_dlclose_funcdlclose = NULL

Macro Definition Documentation



Typedef Documentation

◆ loader_data

typedef struct _loader_data loader_data

Function Documentation

◆ 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 

◆ find_loader()

static loader_data* find_loader ( const char *  filename)

◆ add_internal_loaders()

static void add_internal_loaders ( void  )

◆ 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_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_clear_error()

void simage_clear_error ( void  )

◆ 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_add_loader()

void* simage_add_loader ( const struct simage_plugin plugin,
int  addbefore 

◆ simage_remove_loader()

void simage_remove_loader ( void *  handle)

◆ cnt_bits()

static int cnt_bits ( int  val,
int *  highbit 

◆ 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_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.

◆ 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)

◆ 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,
s_dlsym_func dlsym,
s_dlclose_func dlclose 

Variable Documentation

◆ gdiplus_loader

loader_data gdiplus_loader

◆ targa_loader

loader_data targa_loader

◆ pic_loader

loader_data pic_loader

◆ rgb_loader

loader_data rgb_loader

◆ first_loader

loader_data* first_loader = NULL

◆ last_loader

loader_data* last_loader = NULL

◆ simage_error_msg

char simage_error_msg[512+1]

◆ dlopen

s_dlopen_func* dlopen = NULL

◆ dlsym

s_dlsym_func* dlsym = NULL

◆ dlclose

s_dlclose_func* dlclose = NULL