#include /* all plug-ins need this */ #include /* for "classic" panels */ #include #include XCALL_(LWInstance) create(void *priv,void *context,LWError *err) { return ( LWInstance ) "NIL"; } XCALL_(void) destroy(void *priv) { } XCALL_(unsigned int) flags(void *priv) { return(0); } XCALL_(LWError) copy(void *to,void *from) { //*to=*from; return(NULL); } XCALL_(LWError) load(void *priv,const LWLoadState *lState) { return(NULL); } XCALL_(LWError) save(void *priv,const LWSaveState *sState) { return(NULL); } XCALL_(const char *) describe(LWInstance inst) { return("C Sepia"); } double rnd(double min,double max) { double res; res=(double)rand()/(double)RAND_MAX; res=res*(max-min)+min; return res; } XCALL_( static void ) process( void *priv, const LWFilterAccess *fa ) { LWFVector out; float *r, *g, *b, *a; int x, y; double intense; /* fire up the monitor */ MON_INIT( fa->monitor, fa->height / 16 ); for ( y = 0; y < fa->height; y++ ) { /* get each scanline */ r = fa->getLine( LWBUF_RED, y ); g = fa->getLine( LWBUF_GREEN, y ); b = fa->getLine( LWBUF_BLUE, y ); a = fa->getLine( LWBUF_ALPHA, y ); for ( x = 0; x < fa->width; x++ ) { intense=sqrt(r[x]*r[x]+g[x]*g[x]+b[x]*b[x]); intense=intense/rnd(1.5,1.7); out[ 0 ] = 0.984*intense; out[ 1 ] = 0.855*intense; out[ 2 ] = 0.627*intense; fa->setRGB( x, y, out ); fa->setAlpha( x, y, a[x] ); } if ((y& 15) == 15) if(MON_STEP( fa->monitor )) return; } MON_DONE( fa->monitor ); } XCALL_( int ) ImageHandler( long version, GlobalFunc *global, LWImageFilterHandler *local, void *serverData ) { if ( version != LWIMAGEFILTER_VERSION ) return AFUNC_BADVERSION; local->inst->create = create; local->inst->destroy = destroy; local->inst->copy = copy; local->inst->load = load; local->inst->save = save; local->inst->descln = describe; if ( local->item ) { local->item->useItems = NULL; local->item->changeID = NULL; } local->process = process; local->flags = flags; return AFUNC_OK; } ServerRecord ServerDesc[] = { { LWIMAGEFILTER_HCLASS, "C Sepia", ImageHandler }, { NULL } };