/* ==================================================================== Read all SHP files in source directory and save to directory '.view' in dest directory. ==================================================================== */ int shp_all_to_bmp( void ) { char path[MAXPATHLEN]; int length; DIR *dir = 0; PG_Shp *shp; struct dirent *dirent = 0; /* open directory */ if ( ( dir = opendir( source_path ) ) == 0 ) { fprintf( stderr, "%s: can't open directory\n", source_path ); return 0; } while ( ( dirent = readdir( dir ) ) != 0 ) { if ( dirent->d_name[0] == '.' ) continue; if ( !strncmp( "tacally.shp", strlower( dirent->d_name ), 11 ) ) continue; if ( !strncmp( "tacgerm.shp", strlower( dirent->d_name ), 11 ) ) continue; if ( !strncmp( "a_", strlower( dirent->d_name ), 2 ) ) continue; length = strlen( dirent->d_name ); if ( (dirent->d_name[length - 1] != 'P' || dirent->d_name[length - 2] != 'H' || dirent->d_name[length - 3] != 'S') && (dirent->d_name[length - 1] != 'p' || dirent->d_name[length - 2] != 'h' || dirent->d_name[length - 3] != 's') ) continue; printf( "%s...\n", dirent->d_name ); if ( ( shp = shp_load( dirent->d_name ) ) == 0 ) continue; snprintf( path, MAXPATHLEN, "%s/.view/%s.bmp", dest_path, dirent->d_name ); SDL_SaveBMP( shp->surf, path ); shp_free( &shp ); } closedir( dir ); return 1; }
static void convert_shp_to_bmp() { PG_Shp *shp; verbosef(1, "Reading from %s\n", input_file); shp = shp_load(input_file); if (!shp) abortf("Input file '%s' could not be loaded\n", input_file); verbosef(1, "Writing to %s\n", output_file); if (SDL_SaveBMP(shp->surf, output_file) < 0) abortf("Could not write to '%s'\n", output_file); }