simage  1.8.3
Coin3D texture image library
Loading...
Searching...
No Matches
simage.h
Go to the documentation of this file.
1#ifndef SIMAGE_H
2#define SIMAGE_H
3
4/*
5 * Copyright (c) Kongsberg Oil & Gas Technologies
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
57/***************************************************************************/
58
62#define __SIMAGE__
63
65#define SIMAGE_VERSION_1_1
66
68#define SIMAGE_VERSION_1_2
69
71#define SIMAGE_VERSION_1_3
72
74#define SIMAGE_VERSION_1_4
75
80#define SIMAGE_VERSION_1_5
81
84#define SIMAGE_VERSION_1_6
85
92#if !defined(SIMAGE_MAJOR_VERSION)
93#undef SIMAGE_MAJOR_VERSION
94#endif /* !SIMAGE_MAJOR_VERSION */
95#if !defined(SIMAGE_MINOR_VERSION)
96#undef SIMAGE_MINOR_VERSION
97#endif /* !SIMAGE_MINOR_VERSION */
98#if !defined(SIMAGE_MICRO_VERSION)
99#undef SIMAGE_MICRO_VERSION
100#endif /* !SIMAGE_MICRO_VERSION */
101#if !defined(SIMAGE_VERSION)
102#undef SIMAGE_VERSION
103#endif /* !SIMAGE_VERSION */
104
105/***************************************************************************/
106
107/* Precaution to avoid an error easily made by the application programmer. */
108#ifdef SIMAGE_DLL_API
109# error Leave the internal SIMAGE_DLL_API define alone.
110#endif /* SIMAGE_DLL_API */
111
143#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
144# ifdef SIMAGE_INTERNAL
145# ifdef SIMAGE_MAKE_DLL
146# define SIMAGE_DLL_API __declspec(dllexport)
147# endif /* SIMAGE_MAKE_DLL */
148# else /* !SIMAGE_INTERNAL */
149# ifdef SIMAGE_DLL
150# define SIMAGE_DLL_API __declspec(dllimport)
151# else /* !SIMAGE_DLL */
152# ifndef SIMAGE_NOT_DLL
153# error Define either SIMAGE_DLL or SIMAGE_NOT_DLL as appropriate for your linkage!
154# endif /* SIMAGE_NOT_DLL */
155# endif /* !SIMAGE_DLL */
156# endif /* !SIMAGE_INTERNAL */
157#endif /* Microsoft Windows */
158
159/* Empty define to avoid errors when _not_ compiling an Microsoft Windows DLL. */
160#ifndef SIMAGE_DLL_API
161# define SIMAGE_DLL_API
162#endif /* !SIMAGE_DLL_API */
163
164/***************************************************************************/
165
166#ifdef __cplusplus
167extern "C" {
168#endif
169
179 SIMAGE_DLL_API void simage_version(int * major, int * minor, int * micro);
180
183 SIMAGE_DLL_API int simage_check_supported(const char * filename);
184
199 SIMAGE_DLL_API unsigned char * simage_read_image(const char * filename,
200 int * width, int * height,
201 int * numcomponents);
202
205 SIMAGE_DLL_API const char * simage_get_last_error(void);
206
210 SIMAGE_DLL_API void simage_free_image(unsigned char * imagedata);
211
216 SIMAGE_DLL_API int simage_next_power_of_two(int val);
217
227 SIMAGE_DLL_API unsigned char * simage_resize(unsigned char * imagedata,
228 int width, int height,
229 int numcomponents,
230 int newwidth, int newheight);
231
236 {
237 unsigned char *(*load_func)(const char * name, int * width, int * height,
238 int * numcomponents);
239 int (*identify_func)(const char * filename,
240 const unsigned char * header, int headerlen);
241 int (*error_func)(char * textbuffer, int bufferlen);
242 };
243
244 SIMAGE_DLL_API void * simage_add_loader(const struct simage_plugin * l,
245 int addbefore);
246 SIMAGE_DLL_API void simage_remove_loader(void * handle);
247
248
249 /*****************************************************************/
250 /**** NOTE: new methods for simage version 1.1 *******************/
251 /*****************************************************************/
252
257 SIMAGE_DLL_API int simage_check_save_supported(const char * filenameextension);
258
262 SIMAGE_DLL_API int simage_save_image(const char * filename,
263 const unsigned char * bytes,
264 int w, int h, int numcomponents,
265 const char * filenameextension);
266
267 SIMAGE_DLL_API void * simage_add_saver(int (*save_func)(const char * name,
268 const unsigned char * bytes,
269 int width, int height, int nc),
270 int (*error_func)(char * textbuffer, int bufferlen),
271 const char * extensions,
272 const char * fullname,
273 const char * description,
274 int addbefore);
275
276 SIMAGE_DLL_API void simage_remove_saver(void * handle);
277 SIMAGE_DLL_API int simage_get_num_savers(void);
278 SIMAGE_DLL_API void * simage_get_saver_handle(int idx);
279 SIMAGE_DLL_API const char * simage_get_saver_extensions(void * handle);
280 SIMAGE_DLL_API const char * simage_get_saver_fullname(void * handle);
281 SIMAGE_DLL_API const char * simage_get_saver_description(void * handle);
282
283
284 /*****************************************************************/
285 /**** NOTE: new methods for simage version 1.2 *******************/
286 /*****************************************************************/
287
288 typedef struct simage_image_s s_image;
289 typedef struct simage_movie_s s_movie;
291 typedef int s_movie_open_func(const char *, s_movie *);
292 typedef int s_movie_create_func(const char *, s_movie *, s_params *);
296
297 SIMAGE_DLL_API s_image * s_image_create(int w, int h, int components,
298 unsigned char * prealloc /* | NULL */);
299 SIMAGE_DLL_API void s_image_destroy(s_image * image);
300
301 SIMAGE_DLL_API int s_image_width(s_image * image);
302 SIMAGE_DLL_API int s_image_height(s_image * image);
303 SIMAGE_DLL_API int s_image_components(s_image * image);
304 SIMAGE_DLL_API unsigned char * s_image_data(s_image * image);
305 SIMAGE_DLL_API void s_image_set(s_image * image, int w, int h, int components,
306 unsigned char * data, int copydata);
307
308 SIMAGE_DLL_API s_image * s_image_load(const char * filename, s_image * prealloc /* | NULL */);
309 SIMAGE_DLL_API int s_image_save(const char * filename, s_image * image,
310 s_params * params /* | NULL */);
311
312 SIMAGE_DLL_API s_movie * s_movie_open(const char * filename);
313
338 SIMAGE_DLL_API s_movie * s_movie_create(const char * filename, s_params * params /* | NULL */);
339
340 SIMAGE_DLL_API s_image * s_movie_get_image(s_movie * movie, s_image * prealloc /* | NULL */,
341 s_params * params /* | NULL */);
342
367 SIMAGE_DLL_API int s_movie_put_image(s_movie * movie, s_image * image,
368 s_params * params /* | NULL */);
369
371 SIMAGE_DLL_API void s_movie_close(s_movie * movie);
372
374 SIMAGE_DLL_API void s_movie_destroy(s_movie * movie);
375
376 SIMAGE_DLL_API void s_movie_importer_add(s_movie_open_func * open,
377 s_movie_get_func * get,
378 s_movie_close_func * close);
379
380 SIMAGE_DLL_API void s_movie_exporter_add(s_movie_create_func * create,
381 s_movie_put_func * put,
382 s_movie_close_func * close);
383
384 enum {
392 };
393
394 SIMAGE_DLL_API s_params * s_params_create(void);
395 SIMAGE_DLL_API s_params * s_params_copy(s_params * params);
396 SIMAGE_DLL_API void s_params_destroy(s_params * params);
397
398 SIMAGE_DLL_API void s_params_set(s_params * params, ...);
399 SIMAGE_DLL_API int s_params_get(s_params * params, ...);
400
401 /*****************************************************************/
402 /**** NOTE: new methods for simage version 1.3 *******************/
403 /*****************************************************************/
404
406 SIMAGE_DLL_API unsigned char * simage_resize3d(unsigned char * imagedata,
407 int width, int height,
408 int numcomponents,
409 int layers,
410 int newwidth, int newheight,
411 int newlayers);
412
413 /*****************************************************************/
414 /**** NOTE: new methods for simage version 1.4 *******************/
415 /*****************************************************************/
416
417 typedef struct simage_stream_s s_stream;
418 typedef int s_stream_open_func(const char *, s_stream *, s_params *);
419 typedef int s_stream_create_func(const char *, s_stream *, s_params *);
420 typedef void * s_stream_get_func(s_stream *, void *, int *, s_params *);
421 typedef int s_stream_put_func(s_stream *, void *, int, s_params *);
423
424 SIMAGE_DLL_API s_stream * s_stream_open(const char * filename,
425 s_params * params /* | NULL */);
426 SIMAGE_DLL_API s_stream * s_stream_create(const char * filename,
427 s_params * params /* | NULL */);
428 SIMAGE_DLL_API void * s_stream_get_buffer(s_stream * stream,
429 void * prealloc /* | NULL */,
430 int *size /* | NULL */,
431 s_params * params /* | NULL */);
432 SIMAGE_DLL_API int s_stream_put_buffer(s_stream * stream, void * buffer,
433 int size,
434 s_params * params /* | NULL */);
435 SIMAGE_DLL_API void s_stream_close(s_stream * stream);
436 SIMAGE_DLL_API void s_stream_destroy(s_stream * stream);
437 SIMAGE_DLL_API s_params * s_stream_params(s_stream * stream);
438
439 SIMAGE_DLL_API void s_stream_importer_add(s_stream_open_func * open,
442
446
447 /*****************************************************************/
448 /**** NOTE: new methods for simage version 1.5 *******************/
449 /*****************************************************************/
450
451 typedef int s_stream_seek_func(s_stream *, int, int, s_params *);
453
454 enum {
458 };
459
460
461 SIMAGE_DLL_API int s_stream_seek(s_stream * stream, int offset, int whence,
462 s_params * params /* | NULL */);
463 SIMAGE_DLL_API int s_stream_tell(s_stream *stream,
464 s_params * params /* | NULL */);
465
471
477
478 enum {
481 };
482 SIMAGE_DLL_API int s_image_set_component_order(s_image * image, int order);
483 SIMAGE_DLL_API int s_image_get_component_order(s_image * image);
484
485 /*****************************************************************/
486 /**** NOTE: new methods for simage version 1.6 *******************/
487 /*****************************************************************/
488
489 SIMAGE_DLL_API s_image * s_image_open(const char * file, int oktoreadall);
490 SIMAGE_DLL_API int s_image_read_line(s_image * image,
491 int line,
492 unsigned char * buf);
493
494 typedef void * s_dlopen_func(const char * filename);
495 typedef void * s_dlsym_func(void * handle, const char * symbolname);
496 typedef void s_dlclose_func(void * handle);
497
501
502
503
504#ifdef __cplusplus
505}
506#endif
507
508#endif /* ! SIMAGE_H */
static s_dlclose_func * dlclose
Definition simage.c:492
static s_dlopen_func * dlopen
Definition simage.c:490
static s_dlsym_func * dlsym
Definition simage.c:491
s_movie * s_movie_create(const char *filename, s_params *params)
Definition movie.c:135
int s_movie_put_func(s_movie *, s_image *, s_params *)
Definition simage.h:294
s_image * s_image_create(int w, int h, int components, unsigned char *prealloc)
Definition simage12.c:30
s_params * s_stream_params(s_stream *stream)
Definition stream.c:204
void s_params_destroy(s_params *params)
Definition params.c:57
s_params * s_params_create(void)
Definition params.c:49
void * simage_get_saver_handle(int idx)
Definition simage_write.c:542
int s_stream_put_func(s_stream *, void *, int, s_params *)
Definition simage.h:421
void s_stream_exporter_add(s_stream_create_func *create, s_stream_put_func *put, s_stream_close_func *close)
Definition stream.c:260
void s_stream_close_func(s_stream *)
Definition simage.h:422
int s_image_read_line(s_image *image, int line, unsigned char *buf)
Definition simage.c:453
s_image * s_movie_get_image(s_movie *movie, s_image *prealloc, s_params *params)
Definition movie.c:163
int simage_next_power_of_two(int val)
Definition simage.c:383
void s_stream_importer_add(s_stream_open_func *open, s_stream_get_func *get, s_stream_close_func *close)
Definition stream.c:225
int simage_check_save_supported(const char *filenameextension)
Definition simage_write.c:515
s_params * s_params_copy(s_params *params)
Definition params.c:94
void simage_remove_saver(void *handle)
Definition simage_write.c:489
s_movie * s_movie_open(const char *filename)
Definition movie.c:106
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)
Definition simage_write.c:469
int s_params_get(s_params *params,...)
Definition params.c:251
void * s_dlsym_func(void *handle, const char *symbolname)
Definition simage.h:495
const char * simage_get_last_error(void)
Definition simage.c:319
int simage_save_image(const char *filename, const unsigned char *bytes, int w, int h, int numcomponents, const char *filenameextension)
Definition simage_write.c:433
int s_stream_create_func(const char *, s_stream *, s_params *)
Definition simage.h:419
const char * simage_get_saver_extensions(void *handle)
Definition simage_write.c:553
int s_image_save(const char *filename, s_image *image, s_params *params)
Definition simage12.c:191
void s_image_set(s_image *image, int w, int h, int components, unsigned char *data, int copydata)
Definition simage12.c:126
void s_movie_close(s_movie *movie)
Definition movie.c:176
int simage_get_num_savers(void)
Definition simage_write.c:524
int s_stream_seek_func(s_stream *, int, int, s_params *)
Definition simage.h:451
void s_stream_close(s_stream *stream)
Definition stream.c:190
void simage_version(int *major, int *minor, int *micro)
Definition simage.c:398
@ SIMAGE_SEEK_END
Definition simage.h:457
@ SIMAGE_SEEK_CUR
Definition simage.h:456
@ SIMAGE_SEEK_SET
Definition simage.h:455
int s_image_set_component_order(s_image *image, int order)
Definition simage12.c:94
const char * simage_get_saver_description(void *handle)
Definition simage_write.c:567
int s_stream_open_func(const char *, s_stream *, s_params *)
Definition simage.h:418
int s_image_width(s_image *image)
Definition simage12.c:72
@ SIMAGE_ORDER_RGB
Definition simage.h:479
@ SIMAGE_ORDER_BGR
Definition simage.h:480
void simage_free_image(unsigned char *imagedata)
Definition simage.c:406
void s_image_destroy(s_image *image)
Definition simage12.c:56
void s_movie_importer_add(s_movie_open_func *open, s_movie_get_func *get, s_movie_close_func *close)
Definition movie.c:199
int s_movie_put_image(s_movie *movie, s_image *image, s_params *params)
Definition movie.c:169
void s_movie_close_func(s_movie *)
Definition simage.h:295
void s_movie_destroy(s_movie *movie)
Definition movie.c:182
int s_stream_seek(s_stream *stream, int offset, int whence, s_params *params)
Definition stream.c:295
int s_stream_put_buffer(s_stream *stream, void *buffer, int size, s_params *params)
Definition stream.c:183
void s_stream_destroy(s_stream *stream)
Definition stream.c:196
void s_dlclose_func(void *handle)
Definition simage.h:496
int s_stream_tell_func(s_stream *, s_params *)
Definition simage.h:452
void * simage_add_loader(const struct simage_plugin *l, int addbefore)
Definition simage.c:335
unsigned char * simage_resize(unsigned char *imagedata, int width, int height, int numcomponents, int newwidth, int newheight)
Definition resize.c:512
const char * simage_get_saver_fullname(void *handle)
Definition simage_write.c:560
int s_movie_create_func(const char *, s_movie *, s_params *)
Definition simage.h:292
void s_stream_exporter_add_ex(s_stream_create_func *create, s_stream_put_func *put, s_stream_seek_func *seek, s_stream_tell_func *tell, s_stream_close_func *close)
Definition stream.c:268
void * s_stream_get_func(s_stream *, void *, int *, s_params *)
Definition simage.h:420
int s_movie_open_func(const char *, s_movie *)
Definition simage.h:291
unsigned char * simage_resize3d(unsigned char *imagedata, int width, int height, int numcomponents, int layers, int newwidth, int newheight, int newlayers)
Definition simage13.c:29
unsigned char * s_image_data(s_image *image)
Definition simage12.c:108
s_stream * s_stream_create(const char *filename, s_params *params)
Definition stream.c:145
s_image * s_image_load(const char *filename, s_image *prealloc)
Definition simage12.c:163
int s_image_get_component_order(s_image *image)
Definition simage12.c:102
void * s_stream_get_buffer(s_stream *stream, void *prealloc, int *size, s_params *params)
Definition stream.c:176
int s_image_components(s_image *image)
Definition simage12.c:86
int s_stream_tell(s_stream *stream, s_params *params)
Definition stream.c:304
void s_stream_importer_add_ex(s_stream_open_func *open, s_stream_get_func *get, s_stream_seek_func *seek, s_stream_tell_func *tell, s_stream_close_func *close)
Definition stream.c:233
void s_params_set(s_params *params,...)
Definition params.c:187
void s_set_dynamic_loader_interface(s_dlopen_func *dlopen, s_dlsym_func *dlsym, s_dlclose_func *dlclose)
Definition simage.c:495
@ S_FUNCTION_PARAM_TYPE
Definition simage.h:391
@ S_INTEGER_PARAM_TYPE
Definition simage.h:385
@ S_DOUBLE_PARAM_TYPE
Definition simage.h:388
@ S_POINTER_PARAM_TYPE
Definition simage.h:390
@ S_FLOAT_PARAM_TYPE
Definition simage.h:387
@ S_BOOL_PARAM_TYPE
Definition simage.h:386
@ S_STRING_PARAM_TYPE
Definition simage.h:389
void * s_dlopen_func(const char *filename)
Definition simage.h:494
s_image * s_movie_get_func(s_movie *, s_image *, s_params *)
Definition simage.h:293
s_image * s_image_open(const char *file, int oktoreadall)
Definition simage.c:415
int s_image_height(s_image *image)
Definition simage12.c:79
unsigned char * simage_read_image(const char *filename, int *width, int *height, int *numcomponents)
Definition simage.c:292
int simage_check_supported(const char *filename)
Definition simage.c:328
s_stream * s_stream_open(const char *filename, s_params *params)
Definition stream.c:111
void simage_remove_loader(void *handle)
Definition simage.c:346
void s_movie_exporter_add(s_movie_create_func *create, s_movie_put_func *put, s_movie_close_func *close)
Definition movie.c:222
Definition simage_private.h:34
Definition movie.c:43
Definition params.c:44
Definition simage.h:236
int(* identify_func)(const char *filename, const unsigned char *header, int headerlen)
Definition simage.h:239
int(* error_func)(char *textbuffer, int bufferlen)
Definition simage.h:241
Definition stream.c:37
s_stream_open_func * open
Definition stream.c:40
s_stream_create_func * create
Definition stream.c:41
s_params * params
Definition stream.c:48
s_stream_get_func * get
Definition stream.c:42
char * filename
Definition stream.c:38
s_stream_tell_func * tell
Definition stream.c:46
s_stream_close_func * close
Definition stream.c:44
s_stream_seek_func * seek
Definition stream.c:45
s_stream_put_func * put
Definition stream.c:43