regions.c
/*
 *
 * FilterRegions -- filter an image by sending sections to a co-process,
 * which returns a mask of segments containing valid image data
 *
 */
- filter an image by sending sections to a co-process,
which returns a mask of segments containing valid image data
- filter an image by sending sections to a co - process which returns a mask of segments containing valid image data
int FilterRegions(Regions reg, int x0, int x1, int y0, int y1, int block,
		  RegionsMask *mask, int *nreg){
  int got;
  char tbuf[SZ_LINE];
  RegionsImageCall imrtn;
  if( !reg || (reg == NOREGIONS) ){
    return 0;
  }
  switch(reg->method){
#if __EMSCRIPTEN__
  case METHOD_EM:
    *mask = FilterRegions_EM(reg, x0, x1, y0, y1, block, &got);
    break;
#else
  case METHOD_C:
    switch(reg->ptype){
    case PTYPE_PROCESS:
    case PTYPE_CONTAINED:
      switch(reg->pipeos){
      case PIPE_WIN32:
#if defined(__CYGWIN__) || defined(__MINGW32__)
	snprintf(tbuf, SZ_LINE-1, "%d %d %d %d %d\n", x0, x1, y0, y1, block);
	WinProcessWrite(reg->ohandle, tbuf, (int)strlen(tbuf));
	*mask = WinProcessRead(reg->ihandle, NULL, -1, &got);
	got /=  sizeof(RegionsMaskRec);
#else
	xerror(stderr, "internal error: no WinProcess without Windows");
	return -1;
#endif
	break;
      default:
	snprintf(tbuf, SZ_LINE-1, "%d %d %d %d %d\n", x0, x1, y0, y1, block);
	ProcessWrite(reg->ochan, tbuf, (int)strlen(tbuf));
	*mask = ProcessRead(reg->ichan, NULL, -1, &got);
	got /=  sizeof(RegionsMaskRec);
	break;
      }
      break;
    case PTYPE_DYNAMIC:
      if( (imrtn=(RegionsImageCall)DLSym(reg->dl, reg->pname)) ){
	*mask = (*imrtn)(x0, x1, y0, y1, block, &got);
      } else {
	return -1;
      }
      break;
    default:
      return -1;
    }
    break;
#endif
  }
  if( nreg ){
    *nreg = reg->nreg;
  }
  return got;
}
int FilterRegions ( Regions reg , int x0 , int x1 , int y0 , int y1 , int block , RegionsMask * mask , int * nreg ) { int got ; char tbuf [ SZ_LINE ] ; RegionsImageCall imrtn ; if ( ! reg || ( reg == NOREGIONS ) ) { return 0 ; } switch ( reg -> method ) { #if __EMSCRIPTEN__ case METHOD_EM : * mask = FilterRegions_EM ( reg , x0 , x1 , y0 , y1 , block , & got ) ; break ; #else case METHOD_C : switch ( reg -> ptype ) { case PTYPE_PROCESS : case PTYPE_CONTAINED : switch ( reg -> pipeos ) { case PIPE_WIN32 : #if defined ( __CYGWIN__ ) || defined ( __MINGW32__ ) snprintf ( tbuf , SZ_LINE - 1 , " \n " , x0 , x1 , y0 , y1 , block ) ; WinProcessWrite ( reg -> ohandle , tbuf , ( int ) strlen ( tbuf ) ) ; * mask = WinProcessRead ( reg -> ihandle , NULL , -1 , & got ) ; got /= sizeof ( RegionsMaskRec ) ; #else xerror ( stderr , " " ) ; return -1 ; #endif break ; default : snprintf ( tbuf , SZ_LINE - 1 , " \n " , x0 , x1 , y0 , y1 , block ) ; ProcessWrite ( reg -> ochan , tbuf , ( int ) strlen ( tbuf ) ) ; * mask = ProcessRead ( reg -> ichan , NULL , -1 , & got ) ; got /= sizeof ( RegionsMaskRec ) ; break ; } break ; case PTYPE_DYNAMIC : if ( ( imrtn = ( RegionsImageCall ) DLSym ( reg -> dl , reg -> pname ) ) ) { * mask = ( * imrtn ) ( x0 , x1 , y0 , y1 , block , & got ) ; } else { return -1 ; } break ; default : return -1 ; } break ; #endif } if ( nreg ) { * nreg = reg -> nreg ; } return got ; }
FilterRegions -- filter an image by sending sections to a co-process,
 which returns a mask of segments containing valid image data
FilterRegions -- filter an image by sending sections to a co - process which returns a mask of segments containing valid image data
/* make sure we have a valid regions */ /* process filter request */ /* write command to process */ /* read back mask records */ /* write command to process */ /* read back mask records */ /* how many include regions? */ /* return the news */