Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
simage_write.c File Reference
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <config.h>
#include <simage.h>
#include <string.h>
#include <ctype.h>
#include <simage_gdiplus.h>
#include <simage_rgb.h>
#include <simage_eps.h>

Data Structures

struct  _saver_data
 

Macros

#define SIMAGE_ERROR_BUFSIZE   512 /* hack warning. Must match define in simage.c */
 

Typedefs

typedef struct _saver_data saver_data
 

Functions

static char * safe_strdup (const char *str)
 
static void safe_strfree (char *str)
 
static int simage_strcasecmp (const char *str1, const char *str2)
 
static void add_saver_data (saver_data *saver, int(*error_func)(char *, int), const char *extensions, const char *fullname, const char *description, int is_internal, int addbefore)
 
static void * add_saver (saver_data *saver, int(*save_func)(const char *, const unsigned char *, int, int, int), int(*error_func)(char *, int), const char *extensions, const char *fullname, const char *description, int is_internal, int addbefore)
 
static void * add_saver_ext (saver_data *saver, int(*save_func)(const char *, const unsigned char *, int, int, int, const char *), int(*error_func)(char *, int), const char *extensions, const char *fullname, const char *description, int is_internal, int addbefore)
 
static saver_datafind_saver (const char *filenameextension)
 
static void str_tolower (char *str)
 
static void add_internal_savers (void)
 
int simage_save_image (const char *filename, const unsigned char *bytes, int width, int height, int numcomponents, const char *filenameextension)
 
void * simage_add_saver (int(*save_func)(const char *name, const unsigned char *bytes, int width, int height, int nc), int(*error_func)(char *textbuffer, int bufferlen), const char *extensions, const char *fullname, const char *description, int addbefore)
 
void simage_remove_saver (void *handle)
 
int simage_check_save_supported (const char *filenameextension)
 
int simage_get_num_savers (void)
 
void * simage_get_saver_handle (int idx)
 
const char * simage_get_saver_extensions (void *handle)
 
const char * simage_get_saver_fullname (void *handle)
 
const char * simage_get_saver_description (void *handle)
 

Variables

static saver_data rgb_saver
 
static saver_data eps_saver
 
static saver_datafirst_saver = NULL
 
static saver_datalast_saver = NULL
 
static char jpegext [] = "jpg,jpeg"
 
static const char jpegfull [] = "The Independent JPEG Group file format"
 
static char pngext [] = "png"
 
static const char pngfull [] = "The PNG file format"
 
static char tiffext [] = "tiff,tif"
 
static const char tifffull [] = "The Tag Image File Format"
 
static char rgbext [] = "rgb,rgba,bw,inta,int"
 
static const char rgbfull [] ="The SGI RGB file format"
 
static char gifext [] = "gif"
 
static const char giffull [] = "The Graphics Interchange Format"
 
static char epsext [] = "eps,ps"
 
static const char epsfull [] ="Encapsulated postscript"
 
char simage_error_msg []
 

Macro Definition Documentation

◆ SIMAGE_ERROR_BUFSIZE

#define SIMAGE_ERROR_BUFSIZE   512 /* hack warning. Must match define in simage.c */

Typedef Documentation

◆ saver_data

typedef struct _saver_data saver_data

Function Documentation

◆ safe_strdup()

static char* safe_strdup ( const char *  str)
static

◆ safe_strfree()

static void safe_strfree ( char *  str)
static

◆ simage_strcasecmp()

static int simage_strcasecmp ( const char *  str1,
const char *  str2 
)
static

◆ add_saver_data()

static void add_saver_data ( saver_data saver,
int(*)(char *, int)  error_func,
const char *  extensions,
const char *  fullname,
const char *  description,
int  is_internal,
int  addbefore 
)
static

◆ add_saver()

static void* add_saver ( saver_data saver,
int(*)(const char *, const unsigned char *, int, int, int)  save_func,
int(*)(char *, int)  error_func,
const char *  extensions,
const char *  fullname,
const char *  description,
int  is_internal,
int  addbefore 
)
static

◆ add_saver_ext()

static void* add_saver_ext ( saver_data saver,
int(*)(const char *, const unsigned char *, int, int, int, const char *)  save_func,
int(*)(char *, int)  error_func,
const char *  extensions,
const char *  fullname,
const char *  description,
int  is_internal,
int  addbefore 
)
static

◆ find_saver()

static saver_data* find_saver ( const char *  filenameextension)
static

◆ str_tolower()

static void str_tolower ( char *  str)
static

◆ add_internal_savers()

static void add_internal_savers ( void  )
static

◆ simage_save_image()

int simage_save_image ( const char *  filename,
const unsigned char *  bytes,
int  w,
int  h,
int  numcomponents,
const char *  filenameextension 
)

Saves image in the format specified in filenameextension. Use simage_check_write_supported first to verify that the file format is supported.

◆ simage_add_saver()

void* simage_add_saver ( int(*)(const char *name, const unsigned char *bytes, int width, int height, int nc)  save_func,
int(*)(char *textbuffer, int bufferlen)  error_func,
const char *  extensions,
const char *  fullname,
const char *  description,
int  addbefore 
)

◆ simage_remove_saver()

void simage_remove_saver ( void *  handle)

◆ simage_check_save_supported()

int simage_check_save_supported ( const char *  filenameextension)

Checks if export is available for a filetype. Returns 1 if a saver of type filenameextension is supported, 0 otherwise. The built-in savers are gif, jpg/jpeg, png, tif/tiff and rgb.

◆ simage_get_num_savers()

int simage_get_num_savers ( void  )

◆ simage_get_saver_handle()

void* simage_get_saver_handle ( int  idx)

◆ simage_get_saver_extensions()

const char* simage_get_saver_extensions ( void *  handle)

◆ simage_get_saver_fullname()

const char* simage_get_saver_fullname ( void *  handle)

◆ simage_get_saver_description()

const char* simage_get_saver_description ( void *  handle)

Variable Documentation

◆ rgb_saver

saver_data rgb_saver
static

◆ eps_saver

saver_data eps_saver
static

◆ first_saver

saver_data* first_saver = NULL
static

◆ last_saver

saver_data* last_saver = NULL
static

◆ jpegext

char jpegext[] = "jpg,jpeg"
static

◆ jpegfull

const char jpegfull[] = "The Independent JPEG Group file format"
static

◆ pngext

char pngext[] = "png"
static

◆ pngfull

const char pngfull[] = "The PNG file format"
static

◆ tiffext

char tiffext[] = "tiff,tif"
static

◆ tifffull

const char tifffull[] = "The Tag Image File Format"
static

◆ rgbext

char rgbext[] = "rgb,rgba,bw,inta,int"
static

◆ rgbfull

const char rgbfull[] ="The SGI RGB file format"
static

◆ gifext

char gifext[] = "gif"
static

◆ giffull

const char giffull[] = "The Graphics Interchange Format"
static

◆ epsext

char epsext[] = "eps,ps"
static

◆ epsfull

const char epsfull[] ="Encapsulated postscript"
static

◆ simage_error_msg

char simage_error_msg[]