typedef FT2_Fonthandle* Imager__Font__FT2;
#endif
+/* These functions are all shared - then comes platform dependant code */
+static int getstr(void *hv_t,char *key,char **store) {
+ SV** svpp;
+ HV* hv=(HV*)hv_t;
+
+ mm_log((1,"getstr(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+
+ if ( !hv_exists(hv,key,strlen(key)) ) return 0;
+
+ svpp=hv_fetch(hv, key, strlen(key), 0);
+ *store=SvPV(*svpp, PL_na );
+
+ return 1;
+}
+
+static int getint(void *hv_t,char *key,int *store) {
+ SV** svpp;
+ HV* hv=(HV*)hv_t;
+
+ mm_log((1,"getint(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+
+ if ( !hv_exists(hv,key,strlen(key)) ) return 0;
+
+ svpp=hv_fetch(hv, key, strlen(key), 0);
+ *store=(int)SvIV(*svpp);
+ return 1;
+}
+
+static int getdouble(void *hv_t,char* key,double *store) {
+ SV** svpp;
+ HV* hv=(HV*)hv_t;
+
+ mm_log((1,"getdouble(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+
+ if ( !hv_exists(hv,key,strlen(key)) ) return 0;
+ svpp=hv_fetch(hv, key, strlen(key), 0);
+ *store=(float)SvNV(*svpp);
+ return 1;
+}
+
+static int getvoid(void *hv_t,char* key,void **store) {
+ SV** svpp;
+ HV* hv=(HV*)hv_t;
+
+ mm_log((1,"getvoid(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
+
+ if ( !hv_exists(hv,key,strlen(key)) ) return 0;
+
+ svpp=hv_fetch(hv, key, strlen(key), 0);
+ *store = INT2PTR(void*, SvIV(*svpp));
+
+ return 1;
+}
+
+static int getobj(void *hv_t,char *key,char *type,void **store) {
+ SV** svpp;
+ HV* hv=(HV*)hv_t;
+
+ mm_log((1,"getobj(hv_t 0x%X, key %s,type %s, store 0x%X)\n",hv_t,key,type,store));
+
+ if ( !hv_exists(hv,key,strlen(key)) ) return 0;
+
+ svpp=hv_fetch(hv, key, strlen(key), 0);
+
+ if (sv_derived_from(*svpp,type)) {
+ IV tmp = SvIV((SV*)SvRV(*svpp));
+ *store = INT2PTR(void*, tmp);
+ } else {
+ mm_log((1,"getobj: key exists in hash but is not of correct type"));
+ return 0;
+ }
+
+ return 1;
+}
+
+UTIL_table_t i_UTIL_table={getstr,getint,getdouble,getvoid,getobj};
void my_SvREFCNT_dec(void *p) {
SvREFCNT_dec((SV*)p);
}
-void
+static void
log_entry(char *string, int level) {
mm_log((level, string));
}
cbd->where = 0;
cbd->used = did_read;
- copy_size = min(size, cbd->used);
+ copy_size = i_min(size, cbd->used);
memcpy(out, cbd->buffer, copy_size);
cbd->where += copy_size;
out += copy_size;
}
/* loads the segments of a fountain fill into an array */
-i_fountain_seg *load_fount_segs(AV *asegs, int *count) {
+static i_fountain_seg *
+load_fount_segs(AV *asegs, int *count) {
/* Each element of segs must contain:
[ start, middle, end, c0, c1, segtype, colortrans ]
start, middle, end are doubles from 0 to 1
#define IFILL_DESTROY(fill) i_fill_destroy(fill);
typedef i_fill_t* Imager__FillHandle;
+/* the m_init_log() function was called init_log(), renamed to reduce
+ potential naming conflicts */
+#define init_log m_init_log
+
MODULE = Imager PACKAGE = Imager::Color PREFIX = ICL_
Imager::Color
}
}
-double
+static double
perm(int n,int k) {
double r;
int i;
#include "dynaload.h"
-#include "XSUB.h" /* so we can compile on threaded perls */
+/* #include "XSUB.h" so we can compile on threaded perls */
+#include "imagei.h"
static symbol_table_t symbol_table={i_has_format,ICL_set_internal,ICL_info,
i_img_new,i_img_empty,i_img_empty_ch,i_img_exorcise,
i_box,i_draw,i_arc,i_copyto,i_copyto_trans,i_rubthru};
-/* These functions are all shared - then comes platform dependant code */
-
-
-int getstr(void *hv_t,char *key,char **store) {
- SV** svpp;
- HV* hv=(HV*)hv_t;
-
- mm_log((1,"getstr(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
-
- if ( !hv_exists(hv,key,strlen(key)) ) return 0;
-
- svpp=hv_fetch(hv, key, strlen(key), 0);
- *store=SvPV(*svpp, PL_na );
-
- return 1;
-}
-
-int getint(void *hv_t,char *key,int *store) {
- SV** svpp;
- HV* hv=(HV*)hv_t;
-
- mm_log((1,"getint(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
-
- if ( !hv_exists(hv,key,strlen(key)) ) return 0;
-
- svpp=hv_fetch(hv, key, strlen(key), 0);
- *store=(int)SvIV(*svpp);
- return 1;
-}
-
-int getdouble(void *hv_t,char* key,double *store) {
- SV** svpp;
- HV* hv=(HV*)hv_t;
-
- mm_log((1,"getdouble(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
-
- if ( !hv_exists(hv,key,strlen(key)) ) return 0;
- svpp=hv_fetch(hv, key, strlen(key), 0);
- *store=(float)SvNV(*svpp);
- return 1;
-}
-
-int getvoid(void *hv_t,char* key,void **store) {
- SV** svpp;
- HV* hv=(HV*)hv_t;
-
- mm_log((1,"getvoid(hv_t 0x%X, key %s, store 0x%X)\n",hv_t,key,store));
-
- if ( !hv_exists(hv,key,strlen(key)) ) return 0;
-
- svpp=hv_fetch(hv, key, strlen(key), 0);
- *store=(void*)SvIV(*svpp);
-
- return 1;
-}
-
-int getobj(void *hv_t,char *key,char *type,void **store) {
- SV** svpp;
- HV* hv=(HV*)hv_t;
-
- mm_log((1,"getobj(hv_t 0x%X, key %s,type %s, store 0x%X)\n",hv_t,key,type,store));
-
- if ( !hv_exists(hv,key,strlen(key)) ) return 0;
-
- svpp=hv_fetch(hv, key, strlen(key), 0);
-
- if (sv_derived_from(*svpp,type)) {
- IV tmp = SvIV((SV*)SvRV(*svpp));
- *store = (void*) tmp;
- } else {
- mm_log((1,"getobj: key exists in hash but is not of correct type"));
- return 0;
- }
-
- return 1;
-}
-
-
-UTIL_table_t UTIL_table={getstr,getint,getdouble,getvoid,getobj};
-
/*
Dynamic loading works like this:
dynaload opens the shared object and
if ( (shl_findsym(&tt_handle, "symbol_table",TYPE_UNDEFINED,(void*)&plugin_symtab))) return NULL;
if ( (shl_findsym(&tt_handle, "util_table",TYPE_UNDEFINED,&plugin_utiltab))) return NULL;
(*plugin_symtab)=&symbol_table;
- (*plugin_utiltab)=&UTIL_table;
+ (*plugin_utiltab)=&i_UTIL_table;
*/
if ( (shl_findsym(&tt_handle, I_INSTALL_TABLES ,TYPE_UNDEFINED, &f ))) return NULL;
mm_log( (1,"Calling install_tables\n") );
- f(&symbol_table,&UTIL_table);
+ f(&symbol_table,&i_UTIL_table);
mm_log( (1,"Call ok.\n") );
if ( (shl_findsym(&tt_handle, I_FUNCTION_LIST ,TYPE_UNDEFINED,(func_ptr*)&function_list))) return NULL;
return NULL;
}
mm_log((1, "Calling install tables\n"));
- f(&symbol_table, &UTIL_table);
+ f(&symbol_table, &i_UTIL_table);
mm_log((1, "Call ok\n"));
if ( (function_list = (func_ptr *)GetProcAddress(d_handle, I_FUNCTION_LIST)) == NULL) {
}
mm_log( (1,"Calling install_tables\n") );
- f(&symbol_table,&UTIL_table);
+ f(&symbol_table,&i_UTIL_table);
mm_log( (1,"Call ok.\n") );
/* (*plugin_symtab)=&symbol_table;
- (*plugin_utiltab)=&UTIL_table; */
+ (*plugin_utiltab)=&i_UTIL_table; */
mm_log( (1,"DSO_open: going to dlsym '%s'\n", I_FUNCTION_LIST ));
if ( (function_list=(func_ptr *)dlsym(d_handle, I_FUNCTION_LIST)) == NULL) {
void *store;
} UTIL_args;
+#if 0
int getobj(void *hv_t,char *key,char *type,void **store);
int getint(void *hv_t,char *key,int *store);
int getdouble(void *hv_t,char *key,double *store);
int getvoid(void *hv_t,char *key,void **store);
-
+#endif
void *DSO_open(char* file,char** evalstring);
int DSO_close(void *);
/* we never actually use the last item - it's the NULL terminator */
#define ERRSTK 20
-i_errmsg error_stack[ERRSTK];
-int error_sp = ERRSTK - 1;
+static i_errmsg error_stack[ERRSTK];
+static int error_sp = ERRSTK - 1;
/* we track the amount of space used each string, so we don't reallocate
space unless we need to.
This also means that a memory tracking library may see the memory
allocated for this as a leak. */
-int error_space[ERRSTK];
+static int error_space[ERRSTK];
static i_error_cb error_cb;
static i_failed_cb failed_cb;
#include "image.h"
+#ifndef IMAGER_EXT_H
+#define IMAGER_EXT_H
+
/* structures for passing data between Imager-plugin and the Imager-module */
typedef struct {
int (*getvoid)(void *hv_t,char* key,void **store);
int (*getobj)(void *hv_t,char* key,char* type,void **store);
} UTIL_table_t;
+
+#endif
static void combine_color(i_color *, i_color *, int, int);
static void combine_colorf(i_fcolor *, i_fcolor *, int, int);
-struct i_combines {
+static struct i_combines {
i_fill_combine_f combine;
i_fill_combinef_f combinef;
} combines[] =
fdist[p] = xd*xd + yd*yd; /* euclidean distance */
break;
case 2: /* euclidean squared */
- fdist[p] = max(xd*xd, yd*yd); /* manhattan distance */
+ fdist[p] = i_max(xd*xd, yd*yd); /* manhattan distance */
break;
default:
m_fatal(3,"i_gradgen: Unknown distance measure\n");
mindist = xd*xd + yd*yd; /* euclidean distance */
break;
case 2: /* euclidean squared */
- mindist = max(xd*xd, yd*yd); /* manhattan distance */
+ mindist = i_max(xd*xd, yd*yd); /* manhattan distance */
break;
default:
m_fatal(3,"i_nearest_color: Unknown distance measure\n");
curdist = xd*xd + yd*yd; /* euclidean distance */
break;
case 2: /* euclidean squared */
- curdist = max(xd*xd, yd*yd); /* manhattan distance */
+ curdist = i_max(xd*xd, yd*yd); /* manhattan distance */
break;
default:
m_fatal(3,"i_nearest_color: Unknown distance measure\n");
mindist = xd*xd + yd*yd; /* euclidean distance */
break;
case 2: /* euclidean squared */
- mindist = max(xd*xd, yd*yd); /* manhattan distance */
+ mindist = i_max(xd*xd, yd*yd); /* manhattan distance */
break;
default:
m_fatal(3,"i_nearest_color: Unknown distance measure\n");
curdist = xd*xd + yd*yd; /* euclidean distance */
break;
case 2: /* euclidean squared */
- curdist = max(xd*xd, yd*yd); /* manhattan distance */
+ curdist = i_max(xd*xd, yd*yd); /* manhattan distance */
break;
default:
m_fatal(3,"i_nearest_color: Unknown distance measure\n");
if (outchans == 1 || outchans == 3)
++outchans;
- xsize = min(im1->xsize, im2->xsize);
- ysize = min(im1->ysize, im2->ysize);
+ xsize = i_min(im1->xsize, im2->xsize);
+ ysize = i_min(im1->ysize, im2->ysize);
out = i_sametype_chans(im1, xsize, ysize, outchans);
mm_log((1,"Initializing fonts\n"));
#ifdef HAVE_LIBT1
- init_t1(t1log);
+ i_init_t1(t1log);
#endif
#ifdef HAVE_LIBTT
- init_tt();
+ i_init_tt();
#endif
#ifdef HAVE_FT2
*/
undef_int
-init_t1(int t1log) {
+i_init_t1(int t1log) {
int init_flags = IGNORE_CONFIGFILE|IGNORE_FONTDATABASE;
mm_log((1,"init_t1()\n"));
*/
undef_int
-init_tt() {
+i_init_tt() {
TT_Error error;
mm_log((1,"init_tt()\n"));
error = TT_Init_FreeType( &engine );
work[6] = matrix[0] * bbox[2] + matrix[1] * bbox[3];
work[7] = matrix[3] * bbox[2] + matrix[4] * bbox[3];
- bbox[0] = floor(min(min(work[0], work[2]),min(work[4], work[6])));
- bbox[1] = floor(min(min(work[1], work[3]),min(work[5], work[7])));
- bbox[2] = ceil(max(max(work[0], work[2]),max(work[4], work[6])));
- bbox[3] = ceil(max(max(work[1], work[3]),max(work[5], work[7])));
+ bbox[0] = floor(i_min(i_min(work[0], work[2]),i_min(work[4], work[6])));
+ bbox[1] = floor(i_min(i_min(work[1], work[3]),i_min(work[5], work[7])));
+ bbox[2] = ceil(i_max(i_max(work[0], work[2]),i_max(work[4], work[6])));
+ bbox[3] = ceil(i_max(i_max(work[1], work[3]),i_max(work[5], work[7])));
}
/*
=cut
*/
static void expand_bounds(int bbox[4], int bbox2[4]) {
- bbox[0] = min(bbox[0], bbox2[0]);
- bbox[1] = min(bbox[1], bbox2[1]);
- bbox[2] = max(bbox[2], bbox2[2]);
- bbox[3] = max(bbox[3], bbox2[3]);
+ bbox[0] = i_min(bbox[0], bbox2[0]);
+ bbox[1] = i_min(bbox[1], bbox2[1]);
+ bbox[2] = i_max(bbox[2], bbox2[2]);
+ bbox[3] = i_max(bbox[3], bbox2[3]);
}
/*
#include "image.h"
-float
+static float
gauss(int x,float std) {
return 1.0/(sqrt(2.0*PI)*std)*exp(-(float)(x)*(float)(x)/(2*std*std));
}
}
result = i_readgif_multi_low(GifFile, count);
- free_gen_read_data(gci);
+ i_free_gen_read_data(gci);
return result;
#else
}
result = i_readgif_low(GifFile, colour_table, colours);
- free_gen_read_data(gci);
+ i_free_gen_read_data(gci);
return result;
#else
gif_push_error();
i_push_error(0, "Cannot create GIF file object");
mm_log((1, "Error in EGifOpenFileHandle, unable to write image.\n"));
- free_gen_write_data(gwd, 0);
+ i_free_gen_write_data(gwd, 0);
return 0;
}
result = i_writegif_low(quant, gf, imgs, count);
- return free_gen_write_data(gwd, result);
+ return i_free_gen_write_data(gwd, result);
#else
i_clear_error();
i_push_error(0, "callbacks not supported with giflib3");
#define minmax(a,b,i) ( ((a>=i)?a: ( (b<=i)?b:i )) )
/* Hack around an obscure linker bug on solaris - probably due to builtin gcc thingies */
-void fake(void) { ceil(1); }
+static void fake(void) { ceil(1); }
static int i_ppix_d(i_img *im, int x, int y, i_color *val);
static int i_gpix_d(i_img *im, int x, int y, i_color *val);
parm[1]=(double)ny;
/* fprintf(stderr,"(%d,%d) ->",nx,ny); */
- rx=op_run(opx,opxl,parm,parmlen);
- ry=op_run(opy,opyl,parm,parmlen);
+ rx=i_op_run(opx,opxl,parm,parmlen);
+ ry=i_op_run(opy,opyl,parm,parmlen);
/* fprintf(stderr,"(%f,%f)\n",rx,ry); */
i_gpix(im,rx,ry,&val);
i_ppix(new_img,nx,ny,&val);
gci->cpos = 0;
gci->length = did_read;
- copy_size = min(length, gci->length);
+ copy_size = i_min(length, gci->length);
memcpy(buf, gci->buffer, copy_size);
gci->cpos += copy_size;
buf += copy_size;
}
/*
-=item free_gen_read_data(i_gen_read_data *)
+=item i_free_gen_read_data(i_gen_read_data *)
Cleans up.
=cut
*/
-void free_gen_read_data(i_gen_read_data *self) {
+void i_free_gen_read_data(i_gen_read_data *self) {
myfree(self);
}
Allocates and initializes the data structure used by i_gen_writer.
-This should be released with L<image.c/free_gen_write_data>
+This should be released with L<image.c/i_free_gen_write_data>
=cut
*/
i_gen_write_data *self = mymalloc(sizeof(i_gen_write_data));
self->cb = cb;
self->userdata = userdata;
- self->maxlength = min(max_length, sizeof(self->buffer));
+ self->maxlength = i_min(max_length, sizeof(self->buffer));
if (self->maxlength < 0)
self->maxlength = sizeof(self->buffer);
self->filledto = 0;
}
/*
-=item free_gen_write_data(i_gen_write_data *info, int flush)
+=item i_free_gen_write_data(i_gen_write_data *info, int flush)
Cleans up the write buffer.
=cut
*/
-int free_gen_write_data(i_gen_write_data *info, int flush)
+int i_free_gen_write_data(i_gen_write_data *info, int flush)
{
int result = !flush ||
info->filledto == 0 ||
#ifdef HAVE_LIBT1
#include <t1lib.h>
-undef_int init_t1( int t1log );
+undef_int i_init_t1( int t1log );
int i_t1_new( char *pfb, char *afm );
int i_t1_destroy( int font_id );
undef_int i_t1_cp( i_img *im, int xb, int yb, int channel, int fontnum, float points, char* str, int len, int align );
-undef_int init_tt( void );
+undef_int i_init_tt( void );
TT_Fonthandle* i_tt_new(char *fontname);
void i_tt_destroy( TT_Fonthandle *handle );
undef_int i_tt_cp( TT_Fonthandle *handle,i_img *im,int xb,int yb,int channel,float points,char* txt,int len,int smooth);
extern int i_gen_reader(i_gen_read_data *info, char *buffer, int need);
extern i_gen_read_data *i_gen_read_data_new(i_read_callback_t cb, char *userdata);
-extern void free_gen_read_data(i_gen_read_data *);
+extern void i_free_gen_read_data(i_gen_read_data *);
/* general writer callback
userdata - the data the user passed into the writer
extern int i_gen_writer(i_gen_write_data *info, char const *data, int size);
extern i_gen_write_data *i_gen_write_data_new(i_write_callback_t cb, char *userdata, int maxlength);
-extern int free_gen_write_data(i_gen_write_data *, int flush);
+extern int i_free_gen_write_data(i_gen_write_data *, int flush);
/* transparency handling for quantized output */
typedef enum i_transp_tag {
extern void i_get_combine(int combine, i_fill_combine_f *, i_fill_combinef_f *);
+#include "ext.h"
+
+extern UTIL_table_t i_UTIL_table;
+
#endif
/* XXX Shouldn't these go away? */
-int min(int a,int b);
-int max(int x,int y);
+int i_min(int a,int b);
+int i_max(int x,int y);
#endif
#undef max
int
-min(int a,int b) {
+i_min(int a,int b) {
if (a<b) return a; else return b;
}
int
-max(int a,int b) {
+i_max(int a,int b) {
if (a>b) return a; else return b;
}
ieb->cpos = ieb->tfill;
while(wrlen > 0) {
- ssize_t rc, wl = min(wrlen, BBSIZ);
+ ssize_t rc, wl = i_min(wrlen, BBSIZ);
mm_log((1, "bufchain_seek: wrlen = %d, wl = %d\n", wrlen, wl));
rc = bufchain_write( ig, TB, wl );
if (rc != wl) m_fatal(0, "bufchain_seek: Unable to extend file\n");
#define JPEG_APP13 0xED /* APP13 marker code */
#define JPGS 16384
-unsigned char fake_eoi[]={(JOCTET) 0xFF,(JOCTET) JPEG_EOI};
+static unsigned char fake_eoi[]={(JOCTET) 0xFF,(JOCTET) JPEG_EOI};
/* Bad design right here */
*/
void
-init_log(const char* name,int level) {
+m_init_log(const char* name,int level) {
log_level = level;
if (level < 0) {
lg_file = NULL;
*/
void m_lhead ( const char *file, int line );
-void init_log( const char *name, int onoff );
+void m_init_log( const char *name, int onoff );
void m_loog(int level,const char *msg, ... );
void m_fatal ( int exitcode,const char *fmt, ... );
/* this is a way to get number of channels from color space
* Color code to channel number */
-int CC2C[PNG_COLOR_MASK_PALETTE|PNG_COLOR_MASK_COLOR|PNG_COLOR_MASK_ALPHA];
+static int CC2C[PNG_COLOR_MASK_PALETTE|PNG_COLOR_MASK_COLOR|PNG_COLOR_MASK_ALPHA];
#define PNG_BYTES_TO_CHECK 4
lset[i].y1 = IMTRUNC(y[i]);
lset[i].x2 = IMTRUNC(x[(i+1)%l]);
lset[i].y2 = IMTRUNC(y[(i+1)%l]);
- lset[i].miny=min(lset[i].y1,lset[i].y2);
- lset[i].maxy=max(lset[i].y1,lset[i].y2);
- lset[i].minx=min(lset[i].x1,lset[i].x2);
- lset[i].maxx=max(lset[i].x1,lset[i].x2);
+ lset[i].miny=i_min(lset[i].y1,lset[i].y2);
+ lset[i].maxy=i_max(lset[i].y1,lset[i].y2);
+ lset[i].minx=i_min(lset[i].x1,lset[i].x2);
+ lset[i].maxx=i_max(lset[i].x1,lset[i].x2);
}
return lset;
}
/* This function must be modified later to do proper blending */
-void
+static void
scanline_flush(i_img *im, ss_scanline *ss, int y, void *ctx) {
int x, ch, tv;
i_color t;
/* Find the y bounds of scanline_slice */
- maxy = min( l->maxy, r->maxy );
- miny = max( l->miny, r->miny );
+ maxy = i_min( l->maxy, r->maxy );
+ miny = i_max( l->miny, r->miny );
- maxy = min( maxy, (y+1)*16 );
- miny = max( miny, y*16 );
+ maxy = i_min( maxy, (y+1)*16 );
+ miny = i_max( miny, y*16 );
- lminx = min( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
- lmaxx = max( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
+ lminx = i_min( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
+ lmaxx = i_max( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
- rminx = min( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
- rmaxx = max( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
+ rminx = i_min( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
+ rmaxx = i_max( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
thin = coarse(lmaxx) >= coarse(rminx);
- startpix = max( coarse(lminx), 0 );
- stoppix = min( coarse(rmaxx-1), ss->linelen-1 );
+ startpix = i_max( coarse(lminx), 0 );
+ stoppix = i_min( coarse(rmaxx-1), ss->linelen-1 );
for(cpix=startpix; cpix<=stoppix; cpix++) {
int lt = coarse(lmaxx-1) >= cpix;
/* Find the y bounds of scanline_slice */
- maxy = min( l->maxy, r->maxy );
- miny = max( l->miny, r->miny );
+ maxy = i_min( l->maxy, r->maxy );
+ miny = i_max( l->miny, r->miny );
- maxy = min( maxy, (y+1)*16 );
- miny = max( miny, y*16 );
+ maxy = i_min( maxy, (y+1)*16 );
+ miny = i_max( miny, y*16 );
- lminx = min( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
- lmaxx = max( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
+ lminx = i_min( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
+ lmaxx = i_max( p_eval_aty(l, maxy), p_eval_aty(l, miny) );
- rminx = min( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
- rmaxx = max( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
+ rminx = i_min( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
+ rmaxx = i_max( p_eval_aty(r, maxy), p_eval_aty(r, miny) );
thin = coarse(lmaxx) >= coarse(rminx);
/* First step */
startpix = coarse(lminx); /* includes tricky starting pixel */
- stoppix = min(coarse(lmaxx), coarse(rminx) ); /* last pixel is tricky */
+ stoppix = i_min(coarse(lmaxx), coarse(rminx) ); /* last pixel is tricky */
/* handle start pixel */
printf("%2d: step2a pixel\n", cpix);
ss->line[cpix] +=
pixel_coverage(l, cpix*16, cpix*16+16, miny, maxy)
- +(cpix*16+16-min(cpix*16+16, l->maxx))*(maxy-miny)
+ +(cpix*16+16-i_min(cpix*16+16, l->maxx))*(maxy-miny)
-pixel_coverage(r, cpix*16, cpix*16+16, miny, maxy);
}
} else { /* step 2b */
/* step 3 */
- cpix = max(coarse(rminx), coarse(lmaxx+15));
+ cpix = i_max(coarse(rminx), coarse(lmaxx+15));
stoppix = coarse(rmaxx-15);
printf("step3 from %d to %d\n", cpix, stoppix);
*/
-void
+static void
i_poly_aa_low(i_img *im, int l, double *x, double *y, void *ctx, scanline_flusher flusher) {
int i ,k; /* Index variables */
int clc; /* Lines inside current interval */
/* loop on intervals */
for(i=0; i<l-1; i++) {
- int startscan = max( coarse(pset[i].y), 0);
- int stopscan = min( coarse(pset[i+1].y+15), im->ysize);
+ int startscan = i_max( coarse(pset[i].y), 0);
+ int stopscan = i_min( coarse(pset[i+1].y+15), im->ysize);
pcord cc = (pset[i].y + pset[i+1].y)/2;
if (pset[i].y == pset[i+1].y) {
);
}
for(cscl=startscan; cscl<stopscan; cscl++) {
- tempy = min(cscl*16+16, pset[i+1].y);
+ tempy = i_min(cscl*16+16, pset[i+1].y);
POLY_DEB( printf("evaluating scan line %d \n", cscl) );
for(k=0; k<clc-1; k+=2) {
POLY_DEB( printf("evaluating slice %d\n", k) );
i_fill_t *fill;
};
-void
+static void
scanline_flush_cfill(i_img *im, ss_scanline *ss, int y, void *ctx) {
int x, ch, tv;
i_color t;
i_fill_t *fill;
};
-void
+static void
scanline_flush_cfill_f(i_img *im, ss_scanline *ss, int y, void *ctx) {
int x, ch, tv;
int pos;
bbox(boxnum,&r0,&r1,&g0,&g1,&b0,&b1);
- mr=max(abs(b-b0),abs(b-b1));
- mg=max(abs(g-g0),abs(g-g1));
- mb=max(abs(r-r0),abs(r-r1));
+ mr=i_max(abs(b-b0),abs(b-b1));
+ mg=i_max(abs(g-g0),abs(g-g1));
+ mb=i_max(abs(r-r0),abs(r-r1));
return PWR2(mr)+PWR2(mg)+PWR2(mb);
}
if (r0<=r && r<=r1 && g0<=g && g<=g1 && b0<=b && b<=b1) return 0;
- mr=min(abs(b-b0),abs(b-b1));
- mg=min(abs(g-g0),abs(g-g1));
- mb=min(abs(r-r0),abs(r-r1));
+ mr=i_min(abs(b-b0),abs(b-b1));
+ mg=i_min(abs(g-g0),abs(g-g1));
+ mb=i_min(abs(r-r0),abs(r-r1));
mr=PWR2(mr);
mg=PWR2(mg);
}
/* builtin ordered dither maps */
-unsigned char orddith_maps[][64] =
+static unsigned char
+orddith_maps[][64] =
{
{ /* random
this is purely random - it's pretty awful
*/
/* returns the value (brightness) of color from 0 to 1 */
-double hsv_value(i_color color) {
- return max(max(color.rgb.r, color.rgb.g), color.rgb.b) / 255.0;
+static double hsv_value(i_color color) {
+ return i_max(i_max(color.rgb.r, color.rgb.g), color.rgb.b) / 255.0;
}
/* returns the hue (color) of color from 0 to 360 */
-double hsv_hue(i_color color) {
+static double hsv_hue(i_color color) {
int val;
int temp;
- temp = min(min(color.rgb.r, color.rgb.g), color.rgb.b);
- val = max(color.rgb.r, max(color.rgb.g, color.rgb.b));
+ temp = i_min(i_min(color.rgb.r, color.rgb.g), color.rgb.b);
+ val = i_max(color.rgb.r, i_max(color.rgb.g, color.rgb.b));
if (val == 0 || val==temp) {
return 0;
}
}
/* return the saturation of color from 0 to 1 */
-double hsv_sat(i_color color) {
- int value = max(max(color.rgb.r, color.rgb.g), color.rgb.b);
+static double hsv_sat(i_color color) {
+ int value = i_max(i_max(color.rgb.r, color.rgb.g), color.rgb.b);
if (value == 0) {
return 0;
}
else {
- int temp = min(max(color.rgb.r, color.rgb.g), color.rgb.b);
+ int temp = i_min(i_max(color.rgb.r, color.rgb.g), color.rgb.b);
return (value - temp) / (double)value;
}
}
-i_color make_hsv(double hue, double sat, double val) {
+static i_color make_hsv(double hue, double sat, double val) {
int i;
i_color c;
for( i=0; i< MAXCHANNELS; i++) c.channel[i]=0;
return c;
}
-i_color make_rgb(int r, int g, int b) {
+static i_color make_rgb(int r, int g, int b) {
i_color c;
if (r < 0)
r = 0;
#define n_epsilon(x, y) (abs(x)+abs(y))*0.001
static i_color bcol = {{ 0 }};
-i_color rm_run(struct rm_op codes[], size_t code_count,
+i_color i_rm_run(struct rm_op codes[], size_t code_count,
double n_regs[], size_t n_regs_count,
i_color c_regs[], size_t c_regs_count,
i_img *images[], size_t image_count) {
rm_word rout; /* output register */
};
-i_color rm_run(struct rm_op codes[], size_t code_count,
- double n_regs[], size_t n_regs_count,
- i_color c_regs[], size_t c_regs_count,
- i_img *images[], size_t image_count);
+i_color i_rm_run(struct rm_op codes[], size_t code_count,
+ double n_regs[], size_t n_regs_count,
+ i_color c_regs[], size_t c_regs_count,
+ i_img *images[], size_t image_count);
/* op_run(fx, sizeof(fx), parms, 2)) */
#include "stackmach.h"
double
-op_run(int codes[], size_t code_size, double parms[], size_t parm_size) {
+i_op_run(int codes[], size_t code_size, double parms[], size_t parm_size) {
double stack[100];
double *sp = stack;
bcCos
};
-double op_run(int codes[], size_t code_size, double parms[], size_t parm_size);
+double i_op_run(int codes[], size_t code_size, double parms[], size_t parm_size);
/* op_run(fx, sizeof(fx), parms, 2)) */
break;
case Rle:
- ml = min(s->len, pixels-cp);
+ ml = i_min(s->len, pixels-cp);
for(k=0; k<ml; k++) for(j=0; j<s->bytepp; j++)
buf[(cp+k)*s->bytepp+j] = s->cval[j];
cp += ml;
s->len -= ml;
break;
case Raw:
- ml = min(s->len, pixels-cp);
+ ml = i_min(s->len, pixels-cp);
if (s->ig->readcb(s->ig, buf+cp*s->bytepp, ml*s->bytepp) != ml*s->bytepp) return 0;
cp += ml;
s->len -= ml;
for (y = 0; y < height; ++y) {
n_regs[0] = x;
n_regs[1] = y;
- val = rm_run(ops, ops_count, n_regs, n_regs_count, c_regs, c_regs_count,
+ val = i_rm_run(ops, ops_count, n_regs, n_regs_count, c_regs, c_regs_count,
in_imgs, in_imgs_count);
i_ppix(new_img, x, y, &val);
}