![]() |
Coin3D is Free Software, published under the BSD 3-clause license. |
https://coin3d.github.io https://www.kongsberg.com/en/kogt/ |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <config.h>
#include <simage.h>
#include <simage_private.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | _loader_data |
Macros | |
#define | SIMAGE_ERROR_BUFSIZE 512 |
Typedefs | |
typedef struct _loader_data | loader_data |
Functions | |
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_data * | find_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_image * | s_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) |
Variables | |
static loader_data * | first_loader = NULL |
static loader_data * | last_loader = NULL |
char | simage_error_msg [512+1] |
static s_dlopen_func * | dlopen = NULL |
static s_dlsym_func * | dlsym = NULL |
static s_dlclose_func * | dlclose = NULL |
#define SIMAGE_ERROR_BUFSIZE 512 |
Definition at line 288 of file simage.c.
Referenced by simage_read_image().
typedef struct _loader_data loader_data |
|
static |
Definition at line 174 of file simage.c.
References add_loader(), simage_open_funcs::close_func, simage_open_funcs::open_func, _loader_data::openfuncs, simage_open_funcs::read_line_func, simage_cgimage_error(), simage_cgimage_identify(), simage_cgimage_load(), simage_gdiplus_close(), simage_gdiplus_error(), simage_gdiplus_identify(), simage_gdiplus_load(), simage_gdiplus_open(), simage_gdiplus_read_line(), simage_gif_error(), simage_gif_identify(), simage_gif_load(), simage_jasper_error(), simage_jasper_identify(), simage_jasper_load(), simage_jpeg_error(), simage_jpeg_identify(), simage_jpeg_load(), simage_pic_error(), simage_pic_identify(), simage_pic_load(), simage_png_error(), simage_png_identify(), simage_png_load(), simage_qimage_error(), simage_qimage_identify(), simage_qimage_load(), simage_quicktime_error(), simage_quicktime_identify(), simage_quicktime_load(), simage_rgb_close(), simage_rgb_error(), simage_rgb_identify(), simage_rgb_load(), simage_rgb_open(), simage_rgb_read_line(), simage_tga_error(), simage_tga_identify(), simage_tga_load(), simage_tiff_close(), simage_tiff_error(), simage_tiff_identify(), simage_tiff_load(), simage_tiff_open(), simage_tiff_read_line(), simage_xwd_error(), simage_xwd_identify(), and simage_xwd_load().
Referenced by s_image_open(), simage_add_loader(), simage_check_supported(), and simage_read_image().
|
static |
Definition at line 111 of file simage.c.
References simage_plugin::error_func, first_loader, _loader_data::funcs, simage_plugin::identify_func, _loader_data::is_internal, simage_plugin::load_func, _loader_data::next, and _loader_data::openfuncs.
Referenced by add_internal_loaders(), and simage_add_loader().
|
static |
Definition at line 370 of file simage.c.
Referenced by simage_next_power_of_two().
|
static |
Definition at line 150 of file simage.c.
References first_loader, _loader_data::funcs, simage_plugin::identify_func, and _loader_data::next.
Referenced by s_image_open(), simage_check_supported(), and simage_read_image().
s_image* s_image_open | ( | const char * | filename, |
int | oktoreadall | ||
) |
Definition at line 415 of file simage.c.
References add_internal_loaders(), simage_image_s::components, simage_image_s::data, simage_image_s::didalloc, find_loader(), simage_image_s::height, simage_image_s::oktoreadall, simage_open_funcs::open_func, simage_image_s::opendata, simage_image_s::openfilename, _loader_data::openfuncs, simage_image_s::openfuncs, simage_image_s::order, s_image_load(), SIMAGE_ORDER_RGB, and simage_image_s::width.
int s_image_read_line | ( | s_image * | image, |
int | line, | ||
unsigned char * | buf | ||
) |
Definition at line 453 of file simage.c.
References simage_open_funcs::close_func, simage_image_s::components, simage_image_s::data, simage_image_s::height, simage_image_s::oktoreadall, simage_image_s::opendata, simage_image_s::openfilename, simage_image_s::openfuncs, simage_open_funcs::read_line_func, s_image_read_line(), simage_read_image(), and simage_image_s::width.
Referenced by s_image_data(), and s_image_read_line().
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 | ||
) |
Definition at line 335 of file simage.c.
References add_internal_loaders(), add_loader(), simage_plugin::error_func, simage_plugin::identify_func, and simage_plugin::load_func.
int simage_check_supported | ( | const char * | filename | ) |
Checks if image file format is supported. Returns 1 if filename can be loaded, 0 otherwise.
Definition at line 328 of file simage.c.
References add_internal_loaders(), and find_loader().
void simage_clear_error | ( | void | ) |
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)
Definition at line 406 of file simage.c.
Referenced by s_image_load().
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.
Definition at line 319 of file simage.c.
References simage_error_msg.
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.
Definition at line 383 of file simage.c.
References cnt_bits().
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()
Definition at line 292 of file simage.c.
References add_internal_loaders(), simage_plugin::error_func, find_loader(), _loader_data::funcs, simage_plugin::load_func, and SIMAGE_ERROR_BUFSIZE.
Referenced by s_image_load(), and s_image_read_line().
void simage_remove_loader | ( | void * | handle | ) |
Definition at line 346 of file simage.c.
References first_loader, and _loader_data::next.
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.
|
static |
|
static |
|
static |
|
static |
Definition at line 100 of file simage.c.
Referenced by add_loader(), find_loader(), and simage_remove_loader().
|
static |
char simage_error_msg[512+1] |
Definition at line 289 of file simage.c.
Referenced by simage_get_last_error().