stuff
This commit is contained in:
parent
bada172f99
commit
b59168b5d6
@ -8,6 +8,7 @@ pkginclude_HEADERS = \
|
||||
debug.h \
|
||||
dispatch.h \
|
||||
format.h \
|
||||
type.h \
|
||||
fmask.h \
|
||||
mosaic.h \
|
||||
proto.h \
|
||||
@ -24,7 +25,7 @@ pkginclude_HEADERS = \
|
||||
vips.h \
|
||||
vips \
|
||||
intl.h \
|
||||
vbuf.h \
|
||||
buf.h \
|
||||
vipsc++.h
|
||||
|
||||
vipsc++.h:
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifndef IM_VBUF_H
|
||||
#define IM_VBUF_H
|
||||
#ifndef IM_BUF_H
|
||||
#define IM_BUF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -44,41 +44,41 @@ typedef struct {
|
||||
gboolean full; /* String has filled, block writes */
|
||||
int lasti; /* For read-recent */
|
||||
gboolean dynamic; /* We own the string with malloc() */
|
||||
} VBuf;
|
||||
} im_buf_t;
|
||||
|
||||
/* Static init of one of these.
|
||||
*/
|
||||
#define IM_BUF_STATIC( TEXT, MAX ) \
|
||||
{ &TEXT[0], MAX, 0, FALSE, 0, FALSE }
|
||||
|
||||
void im_buf_rewind( VBuf *buf );
|
||||
void im_buf_destroy( VBuf *buf );
|
||||
void im_buf_init( VBuf *buf );
|
||||
void im_buf_set_static( VBuf *buf, char *base, int mx );
|
||||
void im_buf_set_dynamic( VBuf *buf, int mx );
|
||||
void im_buf_init_static( VBuf *buf, char *base, int mx );
|
||||
void im_buf_init_dynamic( VBuf *buf, int mx );
|
||||
gboolean im_buf_appendns( VBuf *buf, const char *str, int sz );
|
||||
gboolean im_buf_appends( VBuf *buf, const char *str );
|
||||
gboolean im_buf_appendline( VBuf *buf, const char *str );
|
||||
gboolean im_buf_appendf( VBuf *buf, const char *fmt, ... )
|
||||
void im_buf_rewind( im_buf_t *buf );
|
||||
void im_buf_destroy( im_buf_t *buf );
|
||||
void im_buf_init( im_buf_t *buf );
|
||||
void im_buf_set_static( im_buf_t *buf, char *base, int mx );
|
||||
void im_buf_set_dynamic( im_buf_t *buf, int mx );
|
||||
void im_buf_init_static( im_buf_t *buf, char *base, int mx );
|
||||
void im_buf_init_dynamic( im_buf_t *buf, int mx );
|
||||
gboolean im_buf_appendns( im_buf_t *buf, const char *str, int sz );
|
||||
gboolean im_buf_appends( im_buf_t *buf, const char *str );
|
||||
gboolean im_buf_appendline( im_buf_t *buf, const char *str );
|
||||
gboolean im_buf_appendf( im_buf_t *buf, const char *fmt, ... )
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
gboolean im_buf_vappendf( VBuf *buf, const char *fmt, va_list ap );
|
||||
gboolean im_buf_appendc( VBuf *buf, char ch );
|
||||
gboolean im_buf_appendg( VBuf *buf, double g );
|
||||
gboolean im_buf_appendsc( VBuf *buf, const char *str );
|
||||
gboolean im_buf_removec( VBuf *buf, char ch );
|
||||
gboolean im_buf_change( VBuf *buf, const char *old, const char * );
|
||||
gboolean im_buf_isempty( VBuf *buf );
|
||||
gboolean im_buf_isfull( VBuf *buf );
|
||||
const char *im_buf_all( VBuf *buf );
|
||||
gboolean im_buf_appendd( VBuf *buf, int d );
|
||||
int im_buf_len( VBuf *buf );
|
||||
gboolean im_buf_vappendf( im_buf_t *buf, const char *fmt, va_list ap );
|
||||
gboolean im_buf_appendc( im_buf_t *buf, char ch );
|
||||
gboolean im_buf_appendg( im_buf_t *buf, double g );
|
||||
gboolean im_buf_appendsc( im_buf_t *buf, const char *str );
|
||||
gboolean im_buf_removec( im_buf_t *buf, char ch );
|
||||
gboolean im_buf_change( im_buf_t *buf, const char *old, const char * );
|
||||
gboolean im_buf_isempty( im_buf_t *buf );
|
||||
gboolean im_buf_isfull( im_buf_t *buf );
|
||||
const char *im_buf_all( im_buf_t *buf );
|
||||
gboolean im_buf_appendd( im_buf_t *buf, int d );
|
||||
int im_buf_len( im_buf_t *buf );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /*IM_VBUF_H*/
|
||||
#endif /*IM_BUF_H*/
|
||||
|
||||
|
141
include/vips/type.h
Normal file
141
include/vips/type.h
Normal file
@ -0,0 +1,141 @@
|
||||
/* VIPS argument types
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifndef IM_TYPE_H
|
||||
#define IM_TYPE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
/* Type names. Old code might use "doublevec" etc. from before we had the
|
||||
* "array" type.
|
||||
*/
|
||||
#define IM_TYPE_NAME_DOUBLE "double" /* im_object is ptr to double */
|
||||
#define IM_TYPE_NAME_INT "integer" /* 32-bit integer */
|
||||
#define IM_TYPE_NAME_COMPLEX "complex" /* Pair of doubles */
|
||||
#define IM_TYPE_NAME_STRING "string" /* Zero-terminated char array */
|
||||
#define IM_TYPE_NAME_IMASK "intmask" /* Integer mask type */
|
||||
#define IM_TYPE_NAME_DMASK "doublemask" /* Double mask type */
|
||||
#define IM_TYPE_NAME_IMAGE "image" /* IMAGE descriptor */
|
||||
#define IM_TYPE_NAME_DISPLAY "display" /* Display descriptor */
|
||||
#define IM_TYPE_NAME_GVALUE "gvalue" /* GValue wrapper */
|
||||
#define IM_TYPE_NAME_ARRAY "array" /* Array of other values of some type */
|
||||
|
||||
/* The arg to the init function is a pointer to the object.
|
||||
*/
|
||||
typedef void (*im_type_init_fn)( im_object *obj );
|
||||
typedef void (*im_type_free_fn)( im_object obj );
|
||||
|
||||
/* A VIPS type.
|
||||
*/
|
||||
typedef struct im__type_t {
|
||||
const char *name; /* Name of type, eg. "double" */
|
||||
size_t size; /* sizeof( im_object repres. ) */
|
||||
im_type_init_fn init; /* Init memory */
|
||||
im_type_free_fn free; /* Destroy object */
|
||||
} im_type_t;
|
||||
|
||||
/* A 'subclass' of im_type_t for array objects, eg. array-of-double.
|
||||
*/
|
||||
typedef struct im__type_array_t {
|
||||
im_type_t parent; /* "array" */
|
||||
im_type_t *type; /* What this is an array of */
|
||||
} im_type_array_t;
|
||||
|
||||
/* Various im_object values.
|
||||
*/
|
||||
typedef struct {
|
||||
char *name; /* Command-line name in */
|
||||
void *mask; /* Mask --- DOUBLE or INT */
|
||||
} im_object_mask_t;
|
||||
|
||||
typedef struct {
|
||||
int n; /* Array length */
|
||||
im_object *array; /* Array */
|
||||
} im_object_array_t;
|
||||
|
||||
/* An argument to a VIPS operation.
|
||||
*/
|
||||
typedef struct im__argument_t {
|
||||
const char *name; /* Eg. "in2" */
|
||||
im_type_t *type; /* Argument type */
|
||||
gboolean input; /* TRUE means arg to operation */
|
||||
} im_argument_t;
|
||||
|
||||
/* Flags for operations. Various hints for UIs about the behaviour of the
|
||||
* operation,
|
||||
*/
|
||||
typedef enum {
|
||||
IM_OPERATION_NONE = 0, /* No flags set */
|
||||
IM_OPERATION_PIO = 0x1, /* Is a partial function */
|
||||
IM_OPERATION_TRANSFORM = 0x2, /* Performs coord transformations */
|
||||
IM_OPERATION_PTOP = 0x4, /* Point-to-point ... can be LUTted */
|
||||
IM_OPERATION_NOCACHE = 0x8 /* Result should not be cached */
|
||||
} im_operation_flags;
|
||||
|
||||
/* Type of a VIPS dispatch funtion.
|
||||
*/
|
||||
typedef int (*im_operation_dispatch_fn)( im_object *argv );
|
||||
|
||||
/* A VIPS operation.
|
||||
*/
|
||||
typedef struct im__operation_t {
|
||||
const char *name; /* eg "im_invert" */
|
||||
const char *desc; /* One line description */
|
||||
im_operation_flags flags; /* Flags for this function */
|
||||
im_operation_dispatch_fn disp; /* Dispatch */
|
||||
int argc; /* Number of args */
|
||||
im_argument_t **argv; /* Arg list */
|
||||
} im_operation_t;
|
||||
|
||||
/* Register/iterate over types.
|
||||
*/
|
||||
im_type_t *im_type_register( const char *name, size_t size,
|
||||
im_type_init_fn init, im_type_free_fn free );
|
||||
void *im_type_map( VSListMap2Fn fn, void *a, void *b );
|
||||
im_type_t *im_type_lookup( const char *name );
|
||||
|
||||
/* Create arguments.
|
||||
*/
|
||||
im_argument_t *im_argument_new( const char *name,
|
||||
im_type_t *type, gboolean input );
|
||||
|
||||
/* Register/iterate/lookup operations.
|
||||
*/
|
||||
im_operation_t *im_operation_register( const char *name, const char *desc,
|
||||
im_operation_flags flags, im_operation_dispatch_fn disp, int argc );
|
||||
void *im_operation_map( VSListMap2Fn fn, void *a, void *b );
|
||||
im_operation_t *im_operation_lookup( const char *name );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus*/
|
||||
|
||||
#endif /*IM_TYPE_H*/
|
@ -495,6 +495,7 @@ typedef struct {
|
||||
/* #include <vips/vector.h> */
|
||||
#include <vips/format.h>
|
||||
#include <vips/dispatch.h>
|
||||
#include <vips/type.h>
|
||||
#include <vips/region.h>
|
||||
#include <vips/semaphore.h>
|
||||
#include <vips/threadgroup.h>
|
||||
|
@ -95,7 +95,7 @@ im_jpeg2vips( const char *name, IMAGE *out )
|
||||
#endif /*HAVE_EXIF*/
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
#include <vips/internal.h>
|
||||
|
||||
/* jpeglib includes jconfig.h, which can define HAVE_STDLIB_H ... which we
|
||||
@ -247,9 +247,9 @@ static void
|
||||
attach_exif_entry( ExifEntry *entry, IMAGE *im )
|
||||
{
|
||||
char name_text[256];
|
||||
VBuf name;
|
||||
im_buf_t name;
|
||||
char value_text[256];
|
||||
VBuf value;
|
||||
im_buf_t value;
|
||||
char exif_value[256];
|
||||
|
||||
im_buf_init_static( &name, name_text, 256 );
|
||||
|
@ -77,7 +77,7 @@ im_magick2vips( const char *filename, IMAGE *im )
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
#include <vips/thread.h>
|
||||
|
||||
#include <magick/api.h>
|
||||
@ -338,7 +338,7 @@ parse_header( Read *read )
|
||||
#error attributes enabled, but no access funcs found
|
||||
#endif
|
||||
char name_text[256];
|
||||
VBuf name;
|
||||
im_buf_t name;
|
||||
|
||||
im_buf_init_static( &name, name_text, 256 );
|
||||
im_buf_appendf( &name, "magick-%s", attr->key );
|
||||
|
@ -115,7 +115,7 @@ im_vips2mimejpeg( IMAGE *in, int qfac )
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
|
||||
/* jpeglib includes jconfig.h, which can define HAVE_STDLIB_H ... which we
|
||||
* also define. Make sure it's turned off.
|
||||
|
@ -1,6 +1,7 @@
|
||||
noinst_LTLIBRARIES = libiofuncs.la
|
||||
|
||||
libiofuncs_la_SOURCES = \
|
||||
type.c \
|
||||
meta.c \
|
||||
base64.h \
|
||||
base64.c \
|
||||
@ -52,7 +53,7 @@ libiofuncs_la_SOURCES = \
|
||||
threadgroup.c \
|
||||
util.c \
|
||||
im_init_world.c \
|
||||
vbuf.c \
|
||||
buf.c \
|
||||
window.c \
|
||||
buffer.c \
|
||||
time.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Some basic util functions.
|
||||
/* string buffers
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,7 +43,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
@ -54,7 +54,7 @@
|
||||
#define MAX_STRSIZE (16000)
|
||||
|
||||
void
|
||||
im_buf_rewind( VBuf *buf )
|
||||
im_buf_rewind( im_buf_t *buf )
|
||||
{
|
||||
buf->i = 0;
|
||||
buf->lasti = 0;
|
||||
@ -67,7 +67,7 @@ im_buf_rewind( VBuf *buf )
|
||||
/* Power on init.
|
||||
*/
|
||||
void
|
||||
im_buf_init( VBuf *buf )
|
||||
im_buf_init( im_buf_t *buf )
|
||||
{
|
||||
buf->base = NULL;
|
||||
buf->mx = 0;
|
||||
@ -78,7 +78,7 @@ im_buf_init( VBuf *buf )
|
||||
/* Reset to power on state ... only needed for dynamic bufs.
|
||||
*/
|
||||
void
|
||||
im_buf_destroy( VBuf *buf )
|
||||
im_buf_destroy( im_buf_t *buf )
|
||||
{
|
||||
if( buf->dynamic ) {
|
||||
if( buf->base ) {
|
||||
@ -93,7 +93,7 @@ im_buf_destroy( VBuf *buf )
|
||||
/* Set to a static string.
|
||||
*/
|
||||
void
|
||||
im_buf_set_static( VBuf *buf, char *base, int mx )
|
||||
im_buf_set_static( im_buf_t *buf, char *base, int mx )
|
||||
{
|
||||
assert( mx >= 4 );
|
||||
|
||||
@ -106,7 +106,7 @@ im_buf_set_static( VBuf *buf, char *base, int mx )
|
||||
}
|
||||
|
||||
void
|
||||
im_buf_init_static( VBuf *buf, char *base, int mx )
|
||||
im_buf_init_static( im_buf_t *buf, char *base, int mx )
|
||||
{
|
||||
im_buf_init( buf );
|
||||
im_buf_set_static( buf, base, mx );
|
||||
@ -115,7 +115,7 @@ im_buf_init_static( VBuf *buf, char *base, int mx )
|
||||
/* Set to a dynamic string.
|
||||
*/
|
||||
void
|
||||
im_buf_set_dynamic( VBuf *buf, int mx )
|
||||
im_buf_set_dynamic( im_buf_t *buf, int mx )
|
||||
{
|
||||
assert( mx >= 4 );
|
||||
|
||||
@ -139,7 +139,7 @@ im_buf_set_dynamic( VBuf *buf, int mx )
|
||||
}
|
||||
|
||||
void
|
||||
im_buf_init_dynamic( VBuf *buf, int mx )
|
||||
im_buf_init_dynamic( im_buf_t *buf, int mx )
|
||||
{
|
||||
im_buf_init( buf );
|
||||
im_buf_set_dynamic( buf, mx );
|
||||
@ -149,7 +149,7 @@ im_buf_init_dynamic( VBuf *buf, int mx )
|
||||
* FALSE on overflow.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_appendns( VBuf *buf, const char *str, int sz )
|
||||
im_buf_appendns( im_buf_t *buf, const char *str, int sz )
|
||||
{
|
||||
int len;
|
||||
int n;
|
||||
@ -191,7 +191,7 @@ im_buf_appendns( VBuf *buf, const char *str, int sz )
|
||||
/* Append a string to a buf. Error on overflow.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_appends( VBuf *buf, const char *str )
|
||||
im_buf_appends( im_buf_t *buf, const char *str )
|
||||
{
|
||||
return( im_buf_appendns( buf, str, -1 ) );
|
||||
}
|
||||
@ -199,7 +199,7 @@ im_buf_appends( VBuf *buf, const char *str )
|
||||
/* Append a character to a buf. Error on overflow.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_appendc( VBuf *buf, char ch )
|
||||
im_buf_appendc( im_buf_t *buf, char ch )
|
||||
{
|
||||
char tiny[2];
|
||||
|
||||
@ -212,7 +212,7 @@ im_buf_appendc( VBuf *buf, char ch )
|
||||
/* Append a double, non-localised. Useful for config files etc.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_appendg( VBuf *buf, double g )
|
||||
im_buf_appendg( im_buf_t *buf, double g )
|
||||
{
|
||||
char text[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
@ -225,7 +225,7 @@ im_buf_appendg( VBuf *buf, double g )
|
||||
/* Swap the rightmost occurence of old for new.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_change( VBuf *buf, const char *old, const char *new )
|
||||
im_buf_change( im_buf_t *buf, const char *old, const char *new )
|
||||
{
|
||||
int olen = strlen( old );
|
||||
int nlen = strlen( new );
|
||||
@ -261,7 +261,7 @@ im_buf_change( VBuf *buf, const char *old, const char *new )
|
||||
/* Remove the last character.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_removec( VBuf *buf, char ch )
|
||||
im_buf_removec( im_buf_t *buf, char ch )
|
||||
{
|
||||
if( buf->full )
|
||||
return( FALSE );
|
||||
@ -277,7 +277,7 @@ im_buf_removec( VBuf *buf, char ch )
|
||||
/* Append to a buf, args as printf. FALSE on overflow.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_appendf( VBuf *buf, const char *fmt, ... )
|
||||
im_buf_appendf( im_buf_t *buf, const char *fmt, ... )
|
||||
{
|
||||
va_list ap;
|
||||
char str[MAX_STRSIZE];
|
||||
@ -292,7 +292,7 @@ im_buf_appendf( VBuf *buf, const char *fmt, ... )
|
||||
/* Append to a buf, args as vprintf. Error on overflow.
|
||||
*/
|
||||
gboolean
|
||||
im_buf_vappendf( VBuf *buf, const char *fmt, va_list ap )
|
||||
im_buf_vappendf( im_buf_t *buf, const char *fmt, va_list ap )
|
||||
{
|
||||
char str[MAX_STRSIZE];
|
||||
|
||||
@ -304,7 +304,7 @@ im_buf_vappendf( VBuf *buf, const char *fmt, va_list ap )
|
||||
/* Read all text from buffer.
|
||||
*/
|
||||
const char *
|
||||
im_buf_all( VBuf *buf )
|
||||
im_buf_all( im_buf_t *buf )
|
||||
{
|
||||
buf->base[buf->i] = '\0';
|
||||
|
||||
@ -312,13 +312,13 @@ im_buf_all( VBuf *buf )
|
||||
}
|
||||
|
||||
gboolean
|
||||
im_buf_isempty( VBuf *buf )
|
||||
im_buf_isempty( im_buf_t *buf )
|
||||
{
|
||||
return( buf->i == 0 );
|
||||
}
|
||||
|
||||
gboolean
|
||||
im_buf_isfull( VBuf *buf )
|
||||
im_buf_isfull( im_buf_t *buf )
|
||||
{
|
||||
return( buf->full );
|
||||
}
|
||||
@ -326,7 +326,7 @@ im_buf_isfull( VBuf *buf )
|
||||
/* Buffer length ... still need to do im_buf_all().
|
||||
*/
|
||||
int
|
||||
im_buf_len( VBuf *buf )
|
||||
im_buf_len( im_buf_t *buf )
|
||||
{
|
||||
return( buf->i );
|
||||
}
|
@ -54,7 +54,7 @@
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/internal.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
#include <vips/thread.h>
|
||||
|
||||
#ifdef OS_WIN32
|
||||
@ -70,7 +70,7 @@
|
||||
*/
|
||||
#define IM_MAX_ERROR (10240)
|
||||
static char im_error_text[IM_MAX_ERROR] = "";
|
||||
static VBuf im_error_buf =
|
||||
static im_buf_t im_error_buf =
|
||||
IM_BUF_STATIC( im_error_text, IM_MAX_ERROR );
|
||||
|
||||
#define IM_DIAGNOSTICS "IM_DIAGNOSTICS"
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
@ -63,7 +63,7 @@ im_updatehist( IMAGE *out, const char *name, int argc, char *argv[] )
|
||||
{
|
||||
int i;
|
||||
char txt[IM_MAX_LINE];
|
||||
VBuf buf;
|
||||
im_buf_t buf;
|
||||
|
||||
im_buf_init_static( &buf, txt, IM_MAX_LINE );
|
||||
im_buf_appends( &buf, name );
|
||||
|
156
libsrc/iofuncs/type.c
Normal file
156
libsrc/iofuncs/type.c
Normal file
@ -0,0 +1,156 @@
|
||||
/* Define built-in VIPS types.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
#ifdef WITH_DMALLOC
|
||||
#include <dmalloc.h>
|
||||
#endif /*WITH_DMALLOC*/
|
||||
|
||||
/* Keep types in a GHashTable, indexed by name.
|
||||
*/
|
||||
static GHashTable *im_type_table = NULL;
|
||||
|
||||
im_type_t *
|
||||
im_type_register( const char *name, size_t size,
|
||||
im_type_init_fn init, im_type_free_fn free )
|
||||
{
|
||||
im_type_t *type;
|
||||
|
||||
if( !(type = IM_NEW( NULL, im_type_t )) )
|
||||
return( NULL );
|
||||
|
||||
type->name = name;
|
||||
type->size = size;
|
||||
type->init = init;
|
||||
type->free = free;
|
||||
|
||||
if( !im_type_table )
|
||||
im_type_table = g_hash_table_new( g_str_hash, g_str_equal );
|
||||
g_hash_table_insert( im_type_table, (char *) name, type );
|
||||
|
||||
return( type );
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
void *a;
|
||||
void *b;
|
||||
VSListMap2Fn fn;
|
||||
void *result;
|
||||
} Pair;
|
||||
|
||||
static gboolean
|
||||
im_type_map_predicate( const char *key, im_type_t *type, Pair *pair )
|
||||
{
|
||||
return( (pair->result == pair->fn( type, pair->a, pair->b )) );
|
||||
}
|
||||
|
||||
void *
|
||||
im_type_map( VSListMap2Fn fn, void *a, void *b )
|
||||
{
|
||||
Pair pair;
|
||||
|
||||
pair.a = a;
|
||||
pair.b = b;
|
||||
pair.fn = fn;
|
||||
pair.result = NULL;
|
||||
|
||||
g_hash_table_find( im_type_table,
|
||||
(GHRFunc) im_type_map_predicate, &pair );
|
||||
|
||||
return( pair.result );
|
||||
}
|
||||
|
||||
im_type_t *
|
||||
im_type_lookup( const char *name )
|
||||
{
|
||||
return( (im_type_t *) g_hash_table_lookup( im_type_table, name ) );
|
||||
}
|
||||
|
||||
/* Free a mask object.
|
||||
*/
|
||||
static void
|
||||
im_object_imask_free( im_object_mask_t *mask )
|
||||
{
|
||||
IM_FREE( mask->name );
|
||||
IM_FREEF( im_free_imask, mask->mask );
|
||||
}
|
||||
|
||||
static void
|
||||
im_object_dmask_free( im_object_mask_t *mask )
|
||||
{
|
||||
IM_FREE( mask->name );
|
||||
IM_FREEF( im_free_dmask, mask->mask );
|
||||
}
|
||||
|
||||
static void
|
||||
gvalue_free( im_object obj )
|
||||
{
|
||||
GValue *value = obj;
|
||||
|
||||
g_value_unset( value );
|
||||
}
|
||||
|
||||
/* Register the base VIPS types.
|
||||
*/
|
||||
void
|
||||
im__type_init( void )
|
||||
{
|
||||
im_type_register( IM_TYPE_NAME_DOUBLE,
|
||||
sizeof( double ), NULL, NULL );
|
||||
im_type_register( IM_TYPE_NAME_INT,
|
||||
sizeof( int ), NULL, NULL );
|
||||
im_type_register( IM_TYPE_NAME_COMPLEX,
|
||||
2 * sizeof( double ), NULL, NULL );
|
||||
im_type_register( IM_TYPE_NAME_STRING,
|
||||
0, NULL, (im_type_free_fn) im_free );
|
||||
im_type_register( IM_TYPE_NAME_IMASK,
|
||||
sizeof( im_object_mask_t ),
|
||||
NULL, (im_type_free_fn) im_object_imask_free );
|
||||
im_type_register( IM_TYPE_NAME_DMASK,
|
||||
sizeof( im_object_mask_t ),
|
||||
NULL, (im_type_free_fn) im_object_dmask_free );
|
||||
im_type_register( IM_TYPE_NAME_IMAGE,
|
||||
0, NULL, NULL );
|
||||
im_type_register( IM_TYPE_NAME_DISPLAY,
|
||||
0, NULL, NULL );
|
||||
im_type_register( IM_TYPE_NAME_GVALUE,
|
||||
0, NULL, gvalue_free );
|
||||
im_type_register( IM_TYPE_NAME_ARRAY,
|
||||
0, NULL, NULL );
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/vbuf.h>
|
||||
#include <vips/buf.h>
|
||||
|
||||
#include "mosaic.h"
|
||||
#include "merge.h"
|
||||
@ -105,7 +105,7 @@ im__lrmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out,
|
||||
{
|
||||
Transformation trn;
|
||||
IMAGE *t1 = im_open_local( out, "im_lrmosaic1:1", "p" );
|
||||
VBuf buf;
|
||||
im_buf_t buf;
|
||||
char text[1024];
|
||||
|
||||
/* Scale, rotate and displace sec.
|
||||
@ -147,7 +147,7 @@ im__tbmerge1( IMAGE *ref, IMAGE *sec, IMAGE *out,
|
||||
{
|
||||
Transformation trn;
|
||||
IMAGE *t1 = im_open_local( out, "im_lrmosaic1:2", "p" );
|
||||
VBuf buf;
|
||||
im_buf_t buf;
|
||||
char text[1024];
|
||||
|
||||
/* Scale, rotate and displace sec.
|
||||
|
Loading…
Reference in New Issue
Block a user