/* * filter.c * * * * Copyright (C) 2002 - 2002 Benninghaus, Rottweil * EMail: el@eb-themen.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _filter_c #define _filter_c #ifdef __cplusplus extern "C" { #endif filtervalues fv1,fv2; int filter_blackwhite( unsigned char *buf, filtervalues * fv ) { int x = 0; int y = 0; unsigned char *p; fv->nr_dark = 0; fv->nr_bright = 0; p = buf; while( y < HEIGHT ) { x = 0; while( x < WIDTH ) { /* p[0] = ( 255 - p[0] ); */ if(p[0] <= ( fv->maxcol - cfg.coltolerance ) ){ p[0] = 0; fv->nr_dark++; } else { p[0] = 255; fv->nr_bright++; } p++; x++; } y++; } return( 1 ); } int filter( unsigned char *buf, filtervalues * fv ) { int x = 0; int y = 0; unsigned char *p; fv->mincol = 255; fv->maxcol = 0; p = buf; while( y < HEIGHT ) { x = 0; while( x < WIDTH ) { /* p[0] = ( 255 - p[0] ); */ if(p[0] < fv->mincol){ fv->mincol = p[0]; fv->min.x = x; fv->min.y = y; } if(p[0] > fv->maxcol){ fv->maxcol = p[0]; fv->max.x = x; fv->max.y = y; } p++; x++; } y++; } filter_blackwhite( buf, fv ); return( 1 ); } #ifdef __cplusplus } #endif #endif /*_filter_c*/