int main(int argc, char **argv)
{
	imageFilename = (argc > 1) ? argv[1] : "butterflies.ppm";


	initGL(argc, argv);
	initCL();

	input = (cl_uint*)malloc(sizeof(unsigned int) * rows * cols);
	output = (cl_uint*)malloc(sizeof(unsigned int) * rows * cols);

	// Read the image
	if (!parse_ppm(imageFilename.c_str(), cols, rows, (unsigned char *)input)) {
		std::cerr << "Error: could not load " << argv[1] << std::endl;
		teardown();
	}

	std::cout << "Commands:" << std::endl;
	std::cout << " <space>  Toggle filter on or off" << std::endl;
	std::cout << " -" << std::endl
		<< "    Reduce filter threshold" << std::endl;
	std::cout << " +" << std::endl
		<< "    Increase filter threshold" << std::endl;
	std::cout << " =" << std::endl
		<< "    Reset filter threshold to default" << std::endl;
	std::cout << " q/<enter>/<esc>" << std::endl
		<< "    Quit the program" << std::endl;

	glutMainLoop();

	teardown(0);
}
示例#2
0
unsigned char* Heightfield::read_ppm( const char* filename )	{

	FILE *stream = fopen( filename, "rb" );
	if( stream == NULL )	{
		printf( "Heightfield::read_ppm ERR: fopen '%s' FAILED\n", filename );
		return( NULL );
	}
	unsigned char* buff = parse_ppm( stream );
	fclose( stream );
	return( buff );
}
示例#3
0
/**
 * im_ppm2vips:
 * @filename: file to load
 * @out: image to write to
 *
 * Read a PPM/PBM/PGM/PFM file into a VIPS image. 
 * It can read 1, 8, 16 and 32 bit images, colour or monochrome,
 * stored in binary or in ASCII. One bit images become 8 bit VIPS images, 
 * with 0 and 255 for 0 and 1.
 *
 * PFM images have the scale factor attached as "pfm-scale".
 *
 * See also: #VipsFormat, im_vips2ppm(), im_meta_get_double()
 *
 * Returns: 0 on success, -1 on error.
 */
int
im_ppm2vips( const char *filename, IMAGE *out )
{
        FILE *fp;

	/* Note that we open in binary mode. If this is a binary PPM, we need
	 * to be able to mmap it.
	 */
	if( !(fp = im__file_open_read( filename, NULL, FALSE )) ) 
                return( -1 );
	if( parse_ppm( fp, filename, out ) ) {
		fclose( fp );
		return( -1 );
	}
	fclose( fp );

	return( 0 );
}