1 #ifndef COIN_SIMAGEWRAPPER_H 2 #define COIN_SIMAGEWRAPPER_H 3 4 /**************************************************************************\ 5 * Copyright (c) Kongsberg Oil & Gas Technologies AS 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * Neither the name of the copyright holder nor the names of its 20 * contributors may be used to endorse or promote products derived from 21 * this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 \**************************************************************************/ 35 36 #ifndef COIN_INTERNAL 37 #error this is a private header file 38 #endif 39 40 #ifdef HAVE_CONFIG_H 41 #include <config.h> 42 #endif /* HAVE_CONFIG_H */ 43 #ifdef HAVE_WINDOWS_H 44 #include <windows.h> 45 #endif /* HAVE_WINDOWS_H */ 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif /* __cplusplus */ 50 51 /* Typedefinitions of function signatures for simage calls we 52 use. We need these for casting from the void-pointer return of 53 dlsym(). 54 55 Note specifically for MSWindows that we do _not_ use the APIENTRY 56 keyword in the function typedefs, as that would set them up with 57 the __stdcall calling convention -- and simage functions are 58 built with the __cdecl calling convention. 59 */ 60 61 typedef void (*simage_version_t)(int *, int *, int *); 62 typedef int (*simage_check_supported_t)(const char * filename); 63 typedef unsigned char * (*simage_read_image_t)(const char * filename, 64 int * w, int * h, 65 int * numcomponents); 66 typedef int (*simage_check_save_supported_t)(const char * filenameextension); 67 typedef int (*simage_save_image_t)(const char * filename, 68 const unsigned char * bytes, 69 int w, int h, int numcomponents, 70 const char * filenameextension); 71 typedef const char * (*simage_get_last_error_t)(void); 72 typedef unsigned char * (*simage_resize_t)(unsigned char * imagedata, 73 int width, int height, 74 int numcomponents, 75 int newwidth, int newheight); 76 typedef unsigned char * (*simage_resize3d_t)(unsigned char * imagedata, 77 int width, int height, 78 int numcomponents, 79 int layers, 80 int newwidth, 81 int newheight, 82 int newlayers); 83 typedef void (*simage_free_image_t)(unsigned char * imagedata); 84 typedef int (*simage_next_power_of_two_t)(int val); 85 86 typedef int (*simage_get_num_savers_t)(void); 87 typedef void * (*simage_get_saver_handle_t)(int idx); 88 typedef const char * (*simage_get_saver_extensions_t)(void * handle); 89 typedef const char * (*simage_get_saver_fullname_t)(void * handle); 90 typedef const char * (*simage_get_saver_description_t)(void * handle); 91 92 /* This define is set up in the simage_wrapper.cpp file, according to 93 whether or not we link static at compile-time or dynamic at 94 run-time to the simage library. */ 95 #if !defined(SIMAGEWRAPPER_ASSUME_SIMAGE) 96 /* This wrapping of the enum and typedefs is necessary to avoid 97 multiple definitions (they are copy'n'pasted from the simage.h 98 header file). */ 99 enum { 100 S_INTEGER_PARAM_TYPE, 101 S_BOOL_PARAM_TYPE = S_INTEGER_PARAM_TYPE, 102 S_FLOAT_PARAM_TYPE, 103 S_DOUBLE_PARAM_TYPE, 104 S_STRING_PARAM_TYPE, 105 S_POINTER_PARAM_TYPE, 106 S_FUNCTION_PARAM_TYPE 107 }; 108 109 typedef struct simage_parameters_s s_params; 110 #endif 111 112 /* Streams implementation was added for simage v1.4. */ 113 #if !defined(SIMAGEWRAPPER_ASSUME_SIMAGE) || !defined(SIMAGE_VERSION_1_4) 114 typedef struct simage_stream_s s_stream; 115 #endif 116 117 typedef s_params * (*s_params_create_t)(void); 118 typedef void (*s_params_destroy_t)(s_params * params); 119 typedef void (*s_params_set_t)(s_params * params, ...); 120 typedef int (*s_params_get_t)(s_params * params, ...); 121 122 typedef s_stream * (*s_stream_open_t)(const char * filename, 123 s_params * params /* | NULL */); 124 typedef void * (*s_stream_get_buffer_t)(s_stream * stream, 125 void * prealloc /* | NULL */, 126 int *size /* | NULL */, 127 s_params * params /* | NULL */); 128 typedef void (*s_stream_close_t)(s_stream * stream); 129 typedef void (*s_stream_destroy_t)(s_stream * stream); 130 typedef s_params * (*s_stream_params_t)(s_stream * stream); 131 132 typedef struct { 133 /* Is the simage library at all available? */ 134 int available; 135 136 /* simage versioning. */ 137 struct { 138 int major, minor, micro; 139 } version; 140 int (*versionMatchesAtLeast)(int major, 141 int minor, 142 int micro); 143 144 simage_version_t simage_version; 145 simage_check_supported_t simage_check_supported; 146 simage_read_image_t simage_read_image; 147 simage_check_save_supported_t simage_check_save_supported; 148 simage_save_image_t simage_save_image; 149 simage_get_last_error_t simage_get_last_error; 150 simage_resize_t simage_resize; 151 simage_free_image_t simage_free_image; 152 simage_next_power_of_two_t simage_next_power_of_two; 153 simage_get_num_savers_t simage_get_num_savers; 154 simage_get_saver_handle_t simage_get_saver_handle; 155 simage_get_saver_extensions_t simage_get_saver_extensions; 156 simage_get_saver_fullname_t simage_get_saver_fullname; 157 simage_get_saver_description_t simage_get_saver_description; 158 159 s_params_create_t s_params_create; 160 s_params_destroy_t s_params_destroy; 161 s_params_set_t s_params_set; 162 s_params_get_t s_params_get; 163 164 simage_resize3d_t simage_resize3d; 165 166 s_stream_open_t s_stream_open; 167 s_stream_get_buffer_t s_stream_get_buffer; 168 s_stream_close_t s_stream_close; 169 s_stream_destroy_t s_stream_destroy; 170 s_stream_params_t s_stream_params; 171 172 } simage_wrapper_t; 173 174 const simage_wrapper_t * simage_wrapper(void); 175 176 #ifdef __cplusplus 177 } 178 #endif /* __cplusplus */ 179 180 #endif /* COIN_SIMAGEWRAPPER_H */ 181